Springboot project optimization and JVM tuning

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

Project tuning

As an engineer, project tuning is something that must be mastered proficiently.
In the SpringBoot project, tuning is mainly carried out through configuration files and configuration of JVM parameters.
There is a good article here, I recommend it to everyone!
SpringBoot project configuration Tomcat and JVM parameters

One, modify the configuration file

About modifying the configuration file application.properties .
SpringBoot project detailed configuration file modification documents

Among them, the more important ones are:

server.tomcat.max-connections=0  # Maximum number of connections that the server accepts and processes at any given time. server.tomcat< span class="hljs-preprocessor">.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.< /span>

Second, Jvm tuning

There is a guide on the Oracle official website for Jvm tuning:
Oracle’s official website’s instructions on Jvm tuning
If you are interested, you can check it out.

three, Jvm tuning actual combat

1, the case of not setting JVM parameters

h3>

I currently have a project. By default, no Jvm parameters are set.
Let me start and take a look.

Write the picture description here2, let’s set the Jvm parameters

For example To configure JVM such a large number of parameters:

-XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio =8 -XX:+UseConcMarkSweepGC< /span>
  • 1

Method 1:
If you are using IDEA and other development tools to start and run the project, you need to debug JDK is too convenient.
Just set the parameter value to VM options.

Write the picture description heremvn clean

  • 1

< img alt="Write the picture description here" title="" src="/wp-content/uploads/images/opensource/spring/1626813515991.net/20180829143805829

Packing the new project:

< pre name="code" class="prettyprint">mvn package -Dmaven.test.skip=true span>

After packaging, enter the path where the Jar package can be run:

here Write picture description $ java -jar -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms1024m -Xmx1024m -Xmn256m < span class="hljs-attribute">-Xss256k -XX:SurvivorRatio=8 -XX< span class="hljs-string">:+UseConcMarkSweepGC newframe-1.0.0.jar span> span>

At this time, if you look at the monitoring again, you will find, It’s Ok already.
The stack is started according to the Jvm parameters set at startup.

Write the picture description here

Leave a Comment

Your email address will not be published.