In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to analyze the WEBLOGIC startup JVM parameter settings. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
1. Heap size setting
The maximum heap size in JVM is limited in three ways: the data model (32-bt or 64-bit) limit of the relevant operating system, the virtual memory limit of the system, and the physical memory limit of the system. In 32-bit systems, it is generally limited to 1.5 Gbps 2GBT 64 for the operating system has no memory limit. I tested on Windows Server 2003 system with 3.5g physical memory and JDK5.0, and the maximum can be set to 1478m.
Typical settings:
O java-Xmx3550m-Xms3550m-Xmn2g-Xss128k
-Xmx3550m: set the maximum available memory of JVM to 3550m.
-Xms3550m: set JVM to make the memory 3550m. This value can be set to the same as-Xmx to prevent JVM from reallocating memory after each garbage collection.
-Xmn2g: set the size of the younger generation to 2G. Whole JVM memory size = younger generation size + older generation size + persistent generation size. The permanent generation usually has a fixed size of 64m, so increasing the size of the younger generation will reduce the size of the old generation. This value has a great impact on system performance, and Sun officially recommends that it be configured as 3Universe 8 of the entire heap.
-Xss128k: sets the stack size for each thread. The stack size of each thread after JDK5.0 is 1m, and the stack size of each thread before is 256K. Adjust the amount of memory required by more applicable threads. Decreasing this value generates more threads under the same physical memory. However, the operating system still has a limit on the number of threads in a process, which cannot be generated indefinitely, and the experience value is about 3000 to 5000.
O java-Xmx3550m-Xms3550m-Xss128k-XX:NewRatio=4-XX:SurvivorRatio=4-XX:MaxPermSize=16m-XX:MaxTenuringThreshold=0
-XX:NewRatio=4: sets the ratio of the younger generation (including Eden and two Survivor zones) to the older generation (excluding the persistent generation). If set to 4, the ratio of the younger generation to the older generation is 1:4, and the younger generation accounts for 1 prime 5 of the whole stack.
-XX:SurvivorRatio=4: sets the ratio of the size of the Eden region to the Survivor region in the younger generation. If set to 4, the ratio of two Survivor regions to one Eden region is 2:4, and one Survivor region accounts for 1 prime 6 of the whole young generation.
-XX:MaxPermSize=16m: set the persistent generation size to 16m.
-XX:MaxTenuringThreshold=0: set the maximum age of garbage. If set to 0, the younger generation will enter the older generation without going through the Survivor area. For more applications of the older generation, it can improve the efficiency. If you set this value to a large value, the younger generation object will be replicated multiple times in the Survivor area, which can increase the survival time of the younger generation of the object and increase the overview of being recycled in the younger generation.
two。 Recycler selection
JVM gives three choices: serial collector, parallel collector and concurrent collector, but serial collector is only suitable for small amount of data, so the choice here is mainly for parallel collector and concurrent collector. By default, JDK5.0 used to use serial collectors, and if you want to use other collectors, you need to add the appropriate parameters at startup. After JDK5.0, JVM will judge based on the current system configuration.
1. Parallel collector with priority to throughput
As mentioned above, the parallel collector is mainly aimed at achieving a certain throughput and is suitable for science and technology and background processing.
Typical configuration:
§java-Xmx3800m-Xms3800m-Xmn2g-Xss128k-XX:+UseParallelGC-XX:ParallelGCThreads=20
-XX:+UseParallelGC: select the garbage collector as the parallel collector. This configuration is valid only for the younger generation. That is, in the above configuration, the younger generation uses concurrent collection, while the older generation still uses serial collection.
-XX:ParallelGCThreads=20: configure the number of threads in the parallel collector, that is, how many threads perform garbage collection at the same time. This value is preferably configured equal to the number of processors.
§java-Xmx3550m-Xms3550m-Xmn2g-Xss128k-XX:+UseParallelGC-XX:ParallelGCThreads=20-XX:+UseParallelOldGC
-XX:+UseParallelOldGC: configure the old generation garbage collection method to collect in parallel. JDK6.0 supports parallel collection of older generations.
§java-Xmx3550m-Xms3550m-Xmn2g-Xss128k-XX:+UseParallelGC-XX:MaxGCPauseMillis=100
-XX:MaxGCPauseMillis=100: set the maximum time for each young generation garbage collection. If this time cannot be met, JVM will automatically adjust the size of the younger generation to meet this value.
§java-Xmx3550m-Xms3550m-Xmn2g-Xss128k-XX:+UseParallelGC-XX:MaxGCPauseMillis=100-XX:+UseAdaptiveSizePolicy
-XX:+UseAdaptiveSizePolicy: when this option is set, the parallel collector automatically selects the size of the younger generation area and the corresponding Survivor area ratio to achieve the minimum corresponding time or collection frequency specified by the target system. This value is recommended to be turned on when using the parallel collector.
two。 Concurrent collector with response time priority
As mentioned above, the main purpose of the concurrent collector is to ensure the response time of the system and reduce the pause time during garbage collection. It is suitable for application server, telecom and so on.
Typical configuration:
§java-Xmx3550m-Xms3550m-Xmn2g-Xss128k-XX:ParallelGCThreads=20-XX:+UseConcMarkSweepGC-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC: set the older generation to collect concurrently. After configuring this in the test, the configuration of-XX:NewRatio=4 failed for an unknown reason. Therefore, at this time, the size of the younger generation is best set with-Xmn.
-XX:+UseParNewGC: set the younger generation to collect in parallel. Can be used in conjunction with CMS collection. Above JDK5.0, JVM will be set according to the system configuration, so it is no longer necessary to set this value.
§java-Xmx3550m-Xms3550m-Xmn2g-Xss128k-XX:+UseConcMarkSweepGC-XX:CMSFullGCsBeforeCompaction=5-XX:+UseCMSCompactAtFullCollection
-XX:CMSFullGCsBeforeCompaction: because the concurrent collector does not compress or clean up the memory space, it will produce "fragments" after running for a period of time, which reduces the running efficiency. This value sets how many times to run GC to compress and organize the memory space.
-XX:+UseCMSCompactAtFullCollection: turn on the compression of the older generation. May affect performance, but can eliminate fragmentation
Auxiliary information
JVM provides a large number of command-line parameters and print information for debugging. The main points are as follows:
O-XX:+PrintGC
Output form: [GC 118250K-> 113543K (130112K), 0.0094143 secs]
[Full GC 121376K-> 10414K (130112K), 0.0650971 secs]
O-XX:+PrintGCDetails
Output form: [GC [DefNew: 8614K-> 781K (9088K), 0.0123035 secs] 118250K-> 113543K (130112K), 0.0124633 secs]
[GC [DefNew: 8614K-> 8614K (9088K), 0.0000665 secs] [Tenured: 112761K-> 10414K (121024K), 0.0433488 secs] 121376K-> 10414K (130112K), 0.0436268 secs]
O-XX:+PrintGCTimeStamps-XX:+PrintGC:PrintGCTimeStamps can be mixed with the above two
Output form: 11.851: [GC 98328K-> 93620K (130112K), 0.0082960 secs]
O-XX:+PrintGCApplicationConcurrentTime: prints the uninterrupted execution time of the program before each garbage collection. Can be mixed with the above
Output form: Application time: 0.5291524 seconds
O-XX:+PrintGCApplicationStoppedTime: the time the program was paused during print garbage collection. Can be mixed with the above
Output form: Total time for which application threads were stopped: 0.0468229 seconds
O-XX:PrintHeapAtGC: detailed stack information before and after printing GC
Output form:
34.702: [GC {Heap before gc invocations=7:
Def new generation total 55296K, used 52568K [0x1ebd0000, 0x227d0000, 0x227d0000)
Eden space 49152K, 99% used [0x1ebd0000, 0x21bce430, 0x21bd0000)
From space 6144K, 55% used [0x221d0000, 0x22527e10, 0x227d0000)
To space 6144K, 0% used [0x21bd0000, 0x21bd0000, 0x221d0000)
Tenured generation total 69632K, used 2696K [0x227d0000, 0x26bd0000, 0x26bd0000)
The space 69632K, 3% used [0x227d0000, 0x22a720f8, 0x22a72200, 0x26bd0000)
Compacting perm gen total 8192 K, used 2898K [0x26bd0000, 0x273d0000, 0x2abd0000)
The space 8192 K, 35% used [0x26bd0000, 0x26ea4ba8, 0x26ea4c00, 0x273d0000)
Ro space 8192 K, 66% used [0x2abd0000, 0x2b12bcc0, 0x2b12be00, 0x2b3d0000)
Rw space 12288K, 46% used [0x2b3d0000, 0x2b972060, 0x2b972200, 0x2bfd0000)
34.735: [DefNew: 52568K-> 3433K (55296K), 0.0072126 secs] 55264K-> 6615K (124928K) Heap after gc invocations=8:
Def new generation total 55296K, used 3433K [0x1ebd0000, 0x227d0000, 0x227d0000)
Eden space 49152K, 0% used [0x1ebd0000, 0x1ebd0000, 0x21bd0000)
From space 6144K, 55% used [0x21bd0000, 0x21f2a5e8, 0x221d0000)
To space 6144K, 0% used [0x221d0000, 0x221d0000, 0x227d0000)
Tenured generation total 69632K, used 3182K [0x227d0000, 0x26bd0000, 0x26bd0000)
The space 69632K, 4% used [0x227d0000, 0x22aeb958, 0x22aeba00, 0x26bd0000)
Compacting perm gen total 8192 K, used 2898K [0x26bd0000, 0x273d0000, 0x2abd0000)
The space 8192 K, 35% used [0x26bd0000, 0x26ea4ba8, 0x26ea4c00, 0x273d0000)
Ro space 8192 K, 66% used [0x2abd0000, 0x2b12bcc0, 0x2b12be00, 0x2b3d0000)
Rw space 12288K, 46% used [0x2b3d0000, 0x2b972060, 0x2b972200, 0x2bfd0000)
}
, 0.0757599 secs]
O-Xloggc:filename: use in conjunction with the above to record relevant log information to a file for analysis.
Summary of common configuration
0. Heap settings
§- Xms: initial heap size
§- Xmx: maximum heap size
§- XX:NewSize=n: set the size of the younger generation
§- XX:NewRatio=n: sets the ratio of the younger generation to the older generation. For example, 3 means that the ratio of the young generation to the old generation is 1:3, and the young generation accounts for 1% of the sum of the young generation and the old generation.
§- XX:SurvivorRatio=n: the ratio of Eden regions to two Survivor regions in the younger generation. Notice that there are two in the Survivor area. For example: 3, which means Eden:Survivor=3:2, and one Survivor area accounts for 1x5 of the whole younger generation.
§- XX:MaxPermSize=n: set persistent generation size
1. Collector Settings
§- XX:+UseSerialGC: setting up the serial collector
§- XX:+UseParallelGC: setting up the parallel collector
§- XX:+UseParalledlOldGC: setting up a parallel older generation collector
§- XX:+UseConcMarkSweepGC: setting up the concurrent collector
two。 Garbage collection statistics
§- XX:+PrintGC
§- XX:+PrintGCDetails
§- XX:+PrintGCTimeStamps
§- Xloggc:filename
3. Parallel Collector Settings
§- XX:ParallelGCThreads=n: sets the number of CPU to use when collecting by the parallel collector. Number of threads collected in parallel.
§- XX:MaxGCPauseMillis=n: set the maximum pause time for parallel collection
§- XX:GCTimeRatio=n: sets the percentage of garbage collection time to program running time. The formula is 1 / (1cm n)
4. Concurrent Collector Settings
§- XX:+CMSIncrementalMode: set to incremental mode. It is suitable for single CPU situation.
§- XX:ParallelGCThreads=n: the number of CPU used when setting the concurrent collector's younger generation collection mode to parallel collection. Number of threads collected in parallel.
IV. Summary of tuning
1. Choice of size of the younger generation
O applications with priority response time: set it as large as possible until it approaches the minimum response time limit of the system (selected according to the actual situation). In this case, the frequency of collection of the younger generation is also the lowest. At the same time, reduce the number of people who reach the older generation.
O Throughput priority applications: set as large as possible, possibly to the extent of Gbit. Because there is no requirement for response time, garbage collection can be carried out in parallel, which is generally suitable for applications above 8CPU.
two。 Choice of the size of the older generation
O applications with priority to response time: the older generation uses concurrent collectors, so its size needs to be set carefully, generally considering some parameters such as concurrent session rate and session duration. If the heap setting is small, it can cause memory fragmentation, high recycling frequency, and application pauses and use the traditional flag cleanup method; if the heap is large, it takes a long time to collect. For the most optimized scheme, you generally need to refer to the following data:
§concurrent garbage collection information
§persistent generation concurrent collection times
§traditional GC information
The proportion of time spent on recycling between the younger and the older generation
Reducing the time spent by the younger and older generations will generally improve the efficiency of the application.
O Throughput priority applications: generally speaking, throughput priority applications have a large younger generation and a younger older generation. The reason is that most of the short-term objects can be recycled as much as possible, reducing the number of medium-term objects, while the older generation can store long-term living objects.
3. Fragmentation problems caused by smaller heaps
Because the older generation of concurrent collectors use marking and clearing algorithms, the heap is not compressed. When the collector collects, it merges adjacent spaces so that they can be allocated to larger objects. However, when the heap space is small, after running for a period of time, there will be "fragments". If the concurrent collector cannot find enough space, then the concurrent collector will stop and then recycle it using the traditional marking and clearing methods. If "fragmentation" occurs, you may need to configure as follows:
O-XX:+UseCMSCompactAtFullCollection: enables compression of the older generation when using a concurrent collector.
O-XX:CMSFullGCsBeforeCompaction=0: when the above configuration is enabled, how many times the FullGC is set here to compress the older generation
The above is how to parse the WEBLOGIC startup JVM parameter settings shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.