Tuning the jvm project papers

Tuning Project

 

As an engineer, project Tuning the matter is the need to get familiar with the matter. In Spring Boot project, mainly through tuning profile parameters and the JVM manner.

 

Here there is a good article, I recommend it to everyone! "Spring Boot project and configure Tomcat JVM parameters"

 

https://zhuanlan.zhihu.com/p/31803182

 

 

1. Modify the configuration file

 

About modifying the configuration file application.properties, recommended "Spring Boot detailed project profiles modify the document."

 

https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html#common-application-properties

 

The more important are:

 

server.tomcat.max-connections=0 # Maximum number of connections that the server accepts and processes at any given time.
server.tomcat.max-http-header-size=0 # Maximum size, in bytes, of the HTTP message header.
server.tomcat.max-http-post-size=0 # Maximum size, in bytes, of the HTTP post content.
server.tomcat.max-threads=0 # Maximum number of worker threads.
server.tomcat.min-spare-threads=0 # Minimum number of worker threads.

 

2. JVM Tuning

 

About JVM Tuning Oracle's official website has a guidance note, we are interested can go and see. "Oracle's official website description of the JVM tuning"

 

https://docs.oracle.com/middleware/11119/wls/PERFM/jvm_tuning.htm#i1146060

 

3. JVM tuning combat

 

3.1 JVM parameter is not provided

 

Now there is a project, it does not set any JVM parameters by default. Now I start to look at.

 

Look at the stack allocation, the default maximum heap memory allocated 8G, obviously unreasonable thing.

 

3.2 Let us set the parameters at JVM

 

For example, to configure the JVM such a large segment parameters:

 

 

-XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC

 

method one


If you are using a development tool such as IDEA project up and running, so it is easy to debug JDK too much. Only need to set the parameter value to VM Options can be.

 

 

Set up, my GC logs and stack allocations have been OK. GC logs:

 

Stack allocation:

 

Second way

 

After the project is suitable for deployment at startup, when using a script or command line to run setup. First pack to the project in the project path, clean up old items:

 
$ mvn clean

 

 

 

Packaging new project:

 

$ mvn package -Dmaven.test.skip=true
Path runnable jar package after the package is completed:
 

 

 

JVM startup settings execution of the operation parameters:

 

 

$ java -jar -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC newframe-1.0.0.jar

This time you look at the monitor, you will find have been OK. JVM stack are in accordance with parameters set to start when initiated.

 

 

JVM arguments about what is the meaning of these settings, please refer to the previous Oracle tuning official document given. I am here to simply say this:

 

-XX:MetaspaceSize=128m (元空间默认大小)
-XX:MaxMetaspaceSize=128m (元空间最大大小)
-Xms1024m (堆最大大小)
-Xmx1024m (堆默认大小)
-Xmn256m (新生代大小)
-Xss256k (棧最大深度大小)
-XX:SurvivorRatio=8 (新生代分区比例 8:2)
-XX:+UseConcMarkSweepGC (指定使用的垃圾收集器,这里使用CMS收集器)
-XX:+PrintGCDetails (打印详细的GC日志)
Knowledge Point
 
After JDK8 the -XX: PermSize and -XX: MaxPermGen removed and replaced by:
 
 
-XX:MetaspaceSize=128m (元空间默认大小)
-XX:MaxMetaspaceSize=128m (元空间最大大小)

 

JDK8 metadata to start the class into localized heap (native heap), which is called a region Metaspace, Chinese yuan name space.

 

Localized memory what good is it?

 

The most direct expression is java.lang.OutOfMemoryError: PermGen space problem will cease to exist. Because the metadata assigned default class is limited only by the size of the local memory, which means that the remaining number of local memory, you can theoretically Metaspace how big this solves the problem of insufficient space (seemingly capacity and also about the operating system's virtual memory ? here is not clear).

 

But let Metaspace become infinite is clearly unrealistic, so we have to limit the size of Metaspace: Use -XX: MaxMetaspaceSize parameter to specify the size of the Metaspace area. MaxMetaspaceSize JVM default setting according to the size dynamically at runtime.

 

Source: https://www.cnblogs.com/jpfss/p/9753215.html

Published 277 original articles · won praise 65 · views 380 000 +

Guess you like

Origin blog.csdn.net/ailiandeziwei/article/details/104363950