Version 1.JDK
Use a higher version of the JDK as much as possible, which often leads to a free performance boost. The current premise is that the version is stable, and the appropriate application server or open source third-party tools, etc., can also be based on this version of stable operation.
2. Byte code Verification
If the compiled code, and the dependent third-party jar packages are trustworthy, you can turn off bytecode validation, which saves class load time and can turn off bytecode validation by-xverify:none.
3.JIT Compilation method
Hotspot has 2 JIT-compiled methods, namely the client mode and the server mode, the client mode is characterized by fast startup, low memory consumption, JIT compiler generated code faster, the server mode will generate more excellent machine code, So the server pattern collects more application behavior. Typically, if the-server mode is selected as a server, this will benefit from long running.
4.GC Tuning
4.1 Principles
1) Try to avoid full GC. The time consuming of full GC is the longest, so the first principle of GC optimization is to avoid full GC.
2) GC Memory maximization principle. The larger the Java heap space, the better the garbage collector's performance and the smoother the application runs.
3) GC Tuning 3 option 2 principle. In throughput, latency, and memory consumption, the performance improvement of one property is always sacrificed to another or two, so it is not possible to reach the 3 optimal, but to choose the 2 points that the application is most interested in tuning.
Here's a more confusing concept, throughput is the amount of work processed per unit of time, such as 1000 transactions/second, and latency refers to the amount of time the application is consuming from the start to the completion of the work, such as a request that takes 10s processing to complete.
Then it should be that the smaller the delay, the greater the throughput ah, feel like a target, reduce the delay will increase the throughput, in fact, these two are not a goal, because the delay refers to the average delay, that is, the average response time. For example, there are a number of requests with short response times and a large number of requests with long response times, and if the system deals with short-response requests each time, it will get high throughput, but due to the long response time of the request is always not processed, it will result in an increase in the overall average response time.
4.2 Explicit GC
You can avoid an explicit full GC by-XX:+DISABLEEXPLICITGC. The GC log with system is the explicit full GC, which is caused by calling System.GC () in the code. However, if you avoid explicit GC, Bytebuffer.allocatedirect () allocated outside of the heap memory can not be recycled, if you use this, is dead anyway.
4.3 Avoid auto-scaling
To avoid automatic memory scaling,-XMS and-xmx, as well as-xx:permsize and-xx:maxpermsize, can be set to the same size, because if auto-scaling occurs, the full GC is triggered frequently, resulting in capacity expansion, So the actual production environment can set two parameters to equal. 
4.4 Heap size configuration  
General rules for heap size configuration:  
Java heap: 3-4 times the old age space after full GC  
Permanent generation: 1.2-1.5 times times ...  
New Generation: 1-1.5 times times ...  
old age: 2-3 times ...  
4.5 garbage collector Select  
Depending on the application to choose a different garbage collector, if you want to get high throughput using the throughput priority collector, usually tuned, you can start with this collector, if not the application requirements, replace with other collectors.  
If you want to get the user and the garbage collector parallel, get a smaller delay, then consider using the CMS collector.  
if it is a single-core machine with a small memory (less than 100M), you can use a serial collector because it is the simplest algorithm and performs best in this scenario.  
if the heap size reaches more than 10G, even if you use USEPARALLELOLDGC parallel processing, the time will be longer, consider using the CMS collector.  
Performance optimization-optimize-JVM tuning