Version: 9.3.16.v20170120 |

Chapter 20. Optimizing Jetty
Previous | Part III. Jetty Administration Guide Home | Next

##### Contact the core Jetty developers at www.webtide.com

private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services for sponsored feature development

## Chapter 20. Optimizing Jetty

There are many ways to optimize Jetty which vary depending on the situation. Are you trying to optimize for number of requests within a given amount of time? Are you trying to optimize the serving of static content? Do you have a large bit of hardware that you want to give entirely over to Jetty to use to its heart’s delight? This chapter examines a few of the many different ways to optimize Jetty.

## Garbage Collection

Tuning the JVM garbage collection (GC) can greatly improve Jetty performance. Specifically, you can avoid pauses while the system performs full garbage collections. Optimal tuning of the GC depends on the behavior of the application and requires detailed analysis, however there are general recommendations.

See official Java 8 Garbage Collection documentation for further assistance.

### Tuning Examples

These options are general to the Oracle JVM, and work in a Java 8 installation. They provide good information about how your JVM is running; based on that initial information, you can then tune more finely.

The most important thing you can do for yourself when considering GC is to capture the GC activity so that you can analyze what is happening and how often it happens.

    -verbose:gc
    -Xloggc:/path/to/myjettybase/logs/gc.log
    -XX:+PrintGCDateStamps
    -XX:+PrintGCTimeStamps
    -XX:+PrintGCDetails
    -XX:+PrintTenuringDistribution
    -XX:+PrintCommandLineFlags
    -XX:+PrintReferenceGC
    -XX:+PrintAdaptiveSizePolicy

There are not many recommended options for GC that can apply to nearly all users.

However, the most obvious one is to disable explicit GC (this is performed regularly by RMI and can introduce an abnormal amount of GC pauses).

    -XX:+DisableExplicitGC

Before you apply any other GC tuning options, monitor your GC logs to see if tuning the CMS makes sense for your environment.

A common setup for those just starting out with GC tuning is included below for reference.

> ### Caution

> This example configuration below could have a negative effect on your application performance, so continued monitoring of your GC log before and after is highly recommended to know if the configuration was beneficial or not.

    -XX:MaxGCPauseMillis=250
    -XX:+UseConcMarkSweepGC
    -XX:ParallelCMSThreads=2
    -XX:+CMSClassUnloadingEnabled
    -XX:+UseCMSCompactAtFullCollection
    -XX:CMSInitiatingOccupancyFraction=80

Previous | Top | Next
Chapter 19. Jetty Runner | Home | High Load

See an error or something missing? Contribute to this documentation at Github!(Generated: 2017-01-20)