JVM optimization Summary (8)-typical configuration Example 2

Source: Internet
Author: User
Common configuration Summary

Heap settings

-XMS:Initial heap size

-Xmx:Max heap size

-XX: newsize = N:Set the young generation size

-XX: newratio = N:Set the ratio of the young generation to the old generation. For example, if the value is 3, the ratio of the young generation to the old generation is. The young generation accounts for 1/4 of the young generation and the old generation.

-XX: Required vorratio = N:The ratio of the Eden zone in the young generation to the two vor zones. Note that there are two vor zones. For example, 3 indicates EDEN: Primary vor =. One primary vor zone accounts for 1/5 of the young generation.

-XX: maxpermsize = N:Set the persistent generation size

Collector settings

-XX: + useserialgc:Set the serial collector

-XX: + useparallelgc:Set parallel collectors

-XX: + useparalledloldgc:Set parallel elder generation collector

-XX: + useconcmarksweepgc:Set concurrent collectors

Garbage collection statistics

-XX: + printgc

-XX: + printgcdetails

-XX: + printgctimestamps

-Xloggc: Filename

Parallel collector settings

-XX: parallelgcthreads = N: Set the number of CPUs used for parallel collector collection. Number of parallel collection threads.

-XX: maxgcpausemillis = N: Sets the maximum pause time for parallel collection.

-XX: gctimeratio = N: Set the percentage of the garbage collection time to the running time. The formula is 1/(1 + n)

Concurrent collector settings

-XX: + cmsincrementalmode:Set to incremental mode. Applicable to a single CPU.

-XX: parallelgcthreads = N:Sets the number of CPUs used by the concurrent collector when the young generation collects data in parallel mode. Number of parallel collection threads.

Optimization Summary

Young Generation Size Selection


Applications with priority over Response Time:Set as large as possible until it is close to the minimum response time limit of the system (depending on the actual situation ). In this case, the collection frequency of the young generation is also the smallest. At the same time, reduce the number of objects that reach the old generation.

Throughput-first applications:The setting is as big as possible and may reach the Gbit level. Because there is no requirement on the response time, garbage collection can be performed in parallel, which is generally suitable for applications with more than 8 CPUs.

Old Generation Size Selection


Applications with priority over Response Time:The concurrency collector is used in the old generation, so the size needs to be carefully set, generally considerConcurrent session RateAndSession durationAnd other parameters. If the heap settings are small, it may cause memory fragmentation, high recovery frequency, and application suspension. The traditional mark clearing method is used. If the heap is large, it takes a long time to collect. For the optimal solution, you generally need to obtain the following data:

1. Concurrent garbage collection information

2. Number of persistent generation concurrent collection times

3. Traditional GC Information

4. percentage of time spent on the recovery of young and old generations

Reducing the time spent by the young and old generations will generally improve application efficiency.

 

Throughput-first applications

Generally, applications with high throughput have a large young generation and a small old generation. The reason is that most of the short-term objects can be recycled as much as possible to reduce the medium-term objects, while the old generation will store the long-term surviving objects as much as possible.

 

Fragmentation problem caused by a small heap

The heap is not compressed because the concurrent collector of the old generation uses the marking and clearing algorithms. When the collector recycles the object, it merges the adjacent space and assigns it to a large object. However, when the heap space is small and runs for a period of time, "fragments" will appear. If the concurrent collector cannot find enough space, the concurrent collector will stop, then, use the traditional marking and clearing methods for recycling. If "fragments" appear, you may need to configure the following:

1.-XX: + usecmscompactatfullcollection:Enable compression for the old generation when the concurrent collector is used.

2.-XX: cmsfullgcsbeforecompaction = 0:When the above configuration is enabled, how many full GC times are set here to compress the old generation?

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.