Springboot project compilation, operation optimization and other related operations

   This blog mainly records the related operations of bloggers when using springboot:

(1) Compile, package and execute the springboot project

           本地:mvn clean package -U --settings D:\devsoft\apache-maven-3.5.3\conf\huxs1settings.xml -Dmaven.test.skip=true -Pdev

        Server: mvn clean package -U -Dmaven.test.skip=true -Ptest

(2) Run the springboot project

        java -jar xxx.jar

       //pinpoint-agent监控的方式启动springboot项目
       nohup java -Xms6144m -Xmx6144m -XX:PermSize=1024m -XX:MaxPermSize=1024m -javaagent:/home/xpp/apm/pinpoint-agent/pinpoint-bootstrap.jar -Dpinpoint.agentId=PP_123.xx.xx.115 -Dpinpoint.applicationName=crs_bb_bb-xxx-data -jar xxx.jar 

(3) SpringBoot enables remote debug and remote monitoring
         a. Enable remote debug

            nohup java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=3286,suspend=n -jar wtp-service-pay-0.0.1-SNAPSHOT.jar --spring.profiles.active=test > wtp-service-pay.log 2>&1 &
         b.开启jvisualVM远程监控

           nohup java \
          -Djava.rmi.server.hostname=12x.xx.xx.112 \
          -Dcom.sun.management.jmxremote \
          -Dcom.sun.management.jmxremote.port=9999 \
          -Dcom.sun.management.jmxremote.authenticate=false \
          -Dcom.sun.management.jmxremote.ssl=false \
          -Dcom.sun.management.jmxremote.rmi.port=9999 \
          -jar wtp-service-pay-0.0.1-SNAPSHOT.jar --spring.profiles.active=test  > wtp-service-pay.log 2>&

         // can also be used

          <!-- JMX monitor -->
          <dependency>
             <groupId>org.jolokia</groupId>
            <artifactId>jolokia-core</artifactId>
          </dependency> 

(4) Production tuning (8G memory, 64-bit linux, JDK1.8) -- stress test tuning result
        nohup java \
              -Xms6144m -Xmx6144m -Xmn2048M -XX:OldSize=4096M -Xss1024k \
              -XX:MetaspaceSize=128m - XX:MaxMetaspaceSize=256m \
              -XX:+UseConcMarkSweepGC \
              -XX:+UseParNewGC \
              -XX:+UseCMSCompactAtFullCollection \
              -XX:CMSFullGCsBeforeCompaction=10 \
              -XX:+CMSClassUnloadingEnabled \
              -XX:+CMSParallelRemarkEnabled \
              -XX:+UseCMSInitiatingOccupancyOnly \
              - XX:CMSInitiatingOccupancyFraction=70 \
              -Djava.rmi.server.hostname=12x.xx.xx.112 \
              -Dcom.sun.management.jmxremote \
              -Dcom.sun.management.jmxremote.port=9999 \
              -Dcom.sun.management.jmxremote.authenticate=false \
              -Dcom.sun.management.jmxremote.ssl=false \
              -Dcom.sun.management.jmxremote.rmi.port=9999 \
              -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=121.xx.xx.112 :8000,suspend=n -jar $JAR_NAME --spring.profiles.active=test              >/home/app/logs/xxxxsearch-catli.out 2>&1 &
     

        Finally a note about the JVM:

        -XX:PermSize=1024M permanent generation size
        -XX:MaxPermSize=1024M -Xms4096M -Xmx4096M MaxPermSize is the maximum permanent generation size,
        -Xmn1024M -XX:SurvivorRatio=8 
        -XX:+DisableExplicitGC Close the program actively calling gc
        -XX:+UseConcMarkSweepGC 
        - XX:+UseParNewGC 
        -XX:+UseCMSCompactAtFullCollection Whether to perform memory cleanup after full garbage collection
        -XX:CMSFullGCsBeforeCompaction=10 How many times for full garbage collection and a memory cleanup -XX
        :+CMSClassUnloadingEnabled Whether to allow (permanent generation) cleanup
        -XX: +CMSParallelRemarkEnabled Reduce marking pause
        -XX:+UseCMSInitiatingOccupancyOnly -XX:+UseCMSInitiatingOccupancyOnly specifies that the HotSpot VM always uses the value of -XX:CMSInitiatingOccupancyFraction as the old space usage limit to start CMS garbage collection. If -XX:+UseCMSInitiatingOccupancyOnly is not used, then HotSpot VM just uses this value to start the first CMS garbage collection, followed by the value automatically calculated by HotSpot VM.
        -XX:CMSInitiatingOccupancyFraction=70 This value specifies what the space occupancy rate of the old generation should be during CMS garbage collection. For example, if you want to start CMS garbage collection when the occupancy rate of the old generation is 65%, you can set -XX:CMSInitiatingOccupancyFraction=65.
        -XX:TargetSurvivorRatio=90 Sets the target usage ratio of the survivor area. The default is 50, that is, the target usage rate of objects in the survivor area is 50%.
        -XX:MaxTenuringThreshold=20 The maximum age threshold for promotion, the default is 15. If the object survives the number of times in the new generation (the number of times after YGC), it still survives, and it will be promoted to the old generation. After each YGC, the age is increased by 1. When the age of the object in the survivor area reaches the TenuringThreshold, it means that the object is a long-lived object and will be directly promoted to the old age.

(5) Monitoring commands during tuning (unfinished here to be continued)

         a. : 行 ps jps 、 jstat 、 jinfo 、 jmap 、 jhat 、 jstack

         b.jdk tools (bin directory): jvisualvm.exe, jconsole.exe 

(6) Common configuration summary
         heap settings -
         Xms: Initial heap size
         -Xmx: Maximum 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, it is 3, which means that the ratio of the young generation to the old generation is 1:3, and the young generation accounts for 1/4 of the sum of the old generation and the young generation.
         -XX:SurvivorRatio=n: The ratio between the Eden area and the two Survivor areas in the young generation ratio. Note that the Survivor area has two. For example: 3, means Eden: Survivor=3:2, a Survivor area occupies 1/5 of the entire young generation
         -XX:MaxPermSize=n: Set the persistent generation size

         Collector settings
         -XX:+UseSerialGC:Set serial collector-
         XX:+UseParallelGC:Set parallel collector-
         XX:+UseParalledlOldGC:Set parallel old generation collector-
         XX:+UseConcMarkSweepGC:Set concurrent collector

         Garbage Collection Statistics
         -XX:+PrintGC
         -XX:+PrintGCDetails
         -XX:+PrintGCTimeStamps
         -Xloggc:filename

         Parallel collector settings
         -XX:ParallelGCThreads=n: Set the number of CPUs used by the parallel collector for collection. Number of parallel collection threads.
         -XX:MaxGCPauseMillis=n: Set the maximum pause time for parallel collection
         -XX:GCTimeRatio=n: Set the percentage of garbage collection time in the program running time. The formula is 1/(1+n)

         Concurrent collector settings
         -XX:+CMSIncrementalMode: set to incremental mode. Suitable for single CPU situation.
         -XX:ParallelGCThreads=n: Set the number of CPUs used when the young generation collection mode of the concurrent collector is parallel collection. Number of parallel collection threads

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324225789&siteId=291194637