In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what is the method of JVM tuning". In daily operation, I believe many people have doubts about what the method of JVM tuning is. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "what is the method of JVM tuning?" Next, please follow the editor to study!
Understand the common command line parameters of JVM
Standard:-at the beginning, all HotSpot supports
Non-standard: starting with-X, the feature version of HotSpot supports specific commands
Unstable: command that may be canceled in the next version at the beginning of-XX
Java-version
Java-X
Tuning code:
Public class OomTest {public static void main (String [] args) {List bytes= new ArrayList (); for (;;) {byte [] b=new byte [1024x1024]; bytes.add (b);} JDK14 java-XX: + PrintCommandLineFlags OomTest.java-XX:G1ConcRefinementThreads=8-XX:GCDrainStackTargetSize=64-XX:InitialHeapSize=268435456-XX:MaxHeapSize=4294967296-XX:MinHeapSize=6815736-XX:+PrintCommandLineFlags-XX:ReservedCodeCacheSize=251658240-XX:+SegmentedCodeCache-XX:+UseCompressedClassPointers-XX:+UseCompressedOops-XX:+UseG1GC Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
JDK8 java-XX: + PrintCommandLineFlags OomTest.java-XX:InitialHeapSize=268435456-XX:MaxHeapSize=4294967296-XX:+PrintCommandLineFlags-XX:+UseCompressedClassPointers-XX:+UseCompressedOops-XX:+UseParallelGC
GC garbage Collector Mode selection
Scientific computing: general choice of throughput, data mining, throughput priority: PS+PO
Response time: website, API G1
What is tuning? (restart once when you're done)
JVM planning and pre-tuning according to demand
Optimize the running JVM environment (slow, Catton)
Solve all kinds of problems during the operation of JVM (OOM)
Tuning, starting with planning
Tuning, starting from the business scenario, no scenario tuning is hooliganism.
No monitoring, no optimization
Steps
Familiar with business scenarios
Response time, pause time [CMS,G1 ZGC] (need to respond to the user)
Throughput = user / (user time + GC time) [PS PO- default]
Select recycler combination
Computing memory requirements
Select CPU (as high as possible)
Set the age and upgrade age
Set log parameters
Observe the log
Find stack information through top jstack
# the first step is to find out which java process has the highest occupancy rate by top. The top# shows as follows: PID USER PR NI VIRT RES SHR S% CPU% MEM TIME+ COMMAND 24525 root 200 4909144 1.421g 6248 S 6.7 18.6 67 top# 52.53 jsvc
# the second step is to use top-Hp Pid to find out which thread has the highest occupancy rate in this pid process. Top-Hp 24525 is clearly as follows: PID USER PR NI VIRT RES SHR S% CPU% MEM TIME+ COMMAND 24624 root 200 4917660 1.427g 14548 S 2.7 18.7 0VR 30.39 jsvc # step 3 use jstack to find stack information of the modified process Need to convert the PID of top- Hp to hexadecimal printf'% x\ n '24624 output: 6603 use jstack-l pid (process) | grep hexadecimal (top- Hp thread PID) find stack jstack-l 24525 | grep 66030 output stack information, use source code to find reasons, use jmap to analyze the memory footprint analysis of java processes, use jmap to cause the system STWjmap-histo process ID | head 20jmap-dump:format=b,file=xxx pid / jmap-histo
Tools: Ali arthas tool use
Java-jar arthas-boot.jar selects java processes by array. Common commands are 1. Dashboard: similar to the top command to prosecute threads in real time 2. Jvm: display all the jvm configurations of the current java process (stack, heap memory, etc. Info) 3. Thread can follow a thread ID: view the list of all threads, followed by thread ID,4. Heapdump: export heap memory, which will cause stw to use jhat-J-mx512M xxx.hprof
5. Redefine hot replacement, online direct replacement of files
Actual jvm parameters running online (G1 for jdk8, maximum heap memory 512m)
#! / bin/bash
SERVER_NAME=xx-xx-serverBUILD_NAME=master-202003042222-13cae098aBASE_DIR=/usr/local/xx/xxx-web-server
Exec java\-Dfile.encoding=UTF-8\-Dlogback.configurationFile=$ {BASE_DIR} / conf/logback.xml\-Xmx512m\-XX:+UseG1GC\-XX:MaxGCPauseMillis=100\ # gc cleanup interval-XX:InitiatingHeapOccupancyPercent=35\ # percentage of heap space used to start G1-verbose:gc\ # Class loading details-XX:+PrintGCDetails\ # GC details-XX:+PrintGCDateStamps\ # print the relative time of gc startup time Between-XX:+PrintGCTimeStamps\ # print send GC time-XX:+PrintGCApplicationStoppedTime\ # print GC stw stop time-Xloggc:$ {BASE_DIR} / logs/jvm_gc.log\ # print GClog-XX:ErrorFile=$ {BASE_DIR} / logs/jvm_err.log\ # print Gc error log-XX:+HeapDumpOnOutOfMemoryError\ # Export oom exception Snapshot of dump exception-XX:HeapDumpPath=$ {BASE_DIR} / logs/jvm_dump_pid % p.hprof\-jar ${BASE_DIR} / bin/xxx-xx-server-$ {BUILD_NAME} .jar ${BASE_DIR} / conf/server.properties so far The study on "what is the method of JVM tuning" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.