JVM Tuning Summary (eight)-Typical configuration Example 2

Source: Internet
Author: User

Common configuration rollups

Heap Settings

-XMS: initial Heap Size

-xmx: Maximum Heap size

-xx:newsize=n: Setting the young generation size

-xx:newratio=n: Sets the ratio of the younger generation to the older generation. such as: 3, the ratio of the young generation and the old generation is 1:3, the young generation of the entire young generation of old generation and 1/4

-xx:survivorratio=n: The ratio of Eden in the young generation to the two survivor districts. Note that there are two survivor districts. such as: 3, indicating Eden:survivor=3:2, a Survivor area accounted for the entire young generation of 1/5

-xx:maxpermsize=n: Setting the persistent generation size

Collector Settings

-XX:+USESERIALGC: setting up the serial collector

-XX:+USEPARALLELGC: setting up a parallel collector

-XX:+USEPARALLEDLOLDGC: setting up a parallel old generation collector

-XX:+USECONCMARKSWEEPGC: Setting the concurrency collector

Garbage collection Statistics

-XX:+PRINTGC

-xx:+printgcdetails

-xx:+printgctimestamps

-xloggc:filename

Parallel collector settings

-xx:parallelgcthreads=n: Sets the number of CPUs to use when the parallel collector is collected. The number of parallel collection threads.

-xx:maxgcpausemillis=n: Set maximum pause time for parallel collection

-xx:gctimeratio=n: Sets the percentage of time that garbage collection takes to run the program. The formula is 1/(1+n)

Concurrent collector Settings

-xx:+cmsincrementalmode: set to incremental mode. Applies to single CPU conditions.

-xx:parallelgcthreads=n: Set the concurrency collector the number of CPUs used by the young generation collection method for parallel collection. The number of parallel collection threads.

Tuning Summary

Young Generation Size Selection

Response Time-first application: as large as possible until the minimum response time limit of the system is approached (depending on the actual situation). In such cases, the frequency at which the young generation collects occurs is also minimal. At the same time, reduce the reach of older generations of objects.

Throughput-First application: as large as possible, may reach Gbit degree. Because there is no requirement for response time, garbage collection can be done in parallel, generally suitable for applications over 8CPU.

Elder Generation Size Selection

Response Time-first application: Older generations Use the concurrency collector, so the size needs to be set carefully, and some parameters, such as concurrent session rate and session duration , are generally considered. If the heap setting is small, it can result in memory fragmentation, high recovery frequency, and application pauses using traditional markup cleanup, and if the heap is large, a longer collection time is required. The most optimized scenario is generally referred to the following data:

1. Concurrent garbage Collection Information

2. Persistent generation of concurrent collection times

3. Traditional GC Information

4. Proportion of time spent in the collection of young and old generations

Reducing the time spent in younger generations and older generations will generally increase the efficiency of your application

Throughput-First applications

General throughput priority applications have a very large young generation and a smaller old generation. The reason for this is that the majority of short-term objects can be recovered as much as possible, reducing medium-term objects, while older generations store long-lived objects.

Fragmentation problems caused by smaller heaps

The heap is not compressed because the old generation of concurrent collectors uses tags and clears the algorithm. When the collector recycles, he merges the adjacent space so that it can be assigned to a larger object. However, when the heap space is small, after a period of time, "fragmentation" occurs, if the concurrent collector does not find enough space, then the concurrent collector will stop, and then use the traditional token, purging method for recycling. If "Fragmentation" occurs, you may need to configure the following:

1. -xx:+usecmscompactatfullcollection: When using the concurrency collector, turn on compression for older generations.

2. -xx:cmsfullgcsbeforecompaction=0: When the above configuration is turned on, how many times the full GC is set here, the old generation is compressed

JVM Tuning Summary (eight)-Typical configuration Example 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.