JVM Performance Optimization Series - (7) in-depth understanding of performance optimization

JVM.jpg

7. depth understanding of performance optimization

7.1 aspects that affect system performance

Factors affecting system performance are many, the following lists some of the common direction system performance optimization:

Screen Shot 2019-12-29 at 4.05.53 PM.png

7.2 commonly used indicators of performance evaluation and testing

Response time

Submitting a request and return between the time response to the request using the generally more concerned about the average response time.

Such as: the time it takes to database queries, the characters back to the time spent on the terminal, access time it takes a Web page;

Concurrency

Refer to the same time, there are actually interact number of requests to the server. And the number of online users of the site association.

Throughput

A measure of the amount of work (request) to complete per unit time.

Such as: database transactions per minute, number of kilobytes per second file transfer, Web server every minute of the number of hits.

Typically, the average response time is shorter, the greater the throughput of the system; the longer the average response time, the system throughput is smaller. However, greater system throughput, not the average response time is shorter.

7.3 common performance optimization tool

For performance tuning systems, generally start from the following three aspects:

  1. Front-end optimization
  2. Application Performance Optimization Service
  3. Storage Performance Optimization

But no matter how optimized, the general principle is:

  • Avoid premature optimization, optimization on the premise that the basic function is completed and the test passes;
  • System a performance test to determine the performance, not performance test guesswork;
  • To find system bottlenecks, divide and rule, and gradually optimized.

Front-end optimization

  • Browser / App
  1. Reducing the number of requests;
  2. Using the client buffer;
  3. Enable compression
  4. Resource file load order
  5. Cookie reduce transmission
  • CDN acceleration

  • Reverse Proxy Cache

  • WEB separate components

Application Performance Optimization Service

1. Cache

Priority to use caching to optimize performance.

2. Cluster

Screen Shot 2019-12-29 at 4.25.51 PM.png

3. Asynchronous

  • Asynchronous and synchronous: Focus on communication mechanism is the result of the message.
  • Blocking and non-blocking: Focus is returned to the caller to wait for the result of the state.

There are four states in combination.

4. Program

  • Level Code : select the appropriate data structures, algorithms select better, less code to write.
  • Concurrent Programming : take full advantage of multi-core CPU, try to use the thread pool, set a reasonable number of threads to make use of all kinds of concurrency framework and tools provided by the JDK; achieve thread-safe class, to avoid security thread; synchronization locks under reduce competition: Zoom Lock range, reducing lock granularity, the lock segment, replacement exclusive lock, read-write locks, locks in place of CAS, the ThreadLocal like.
  • Resource reuse : to reduce the overhead of creating and destroying a lot of system resources. Singleton and pooling techniques.
  • JVM Tuning

Tuning direction GC: GC time is small enough, at least enough number of GC

Most Java applications do not require tuning GC, GC tuning needed most, not the parameters of the problem, the problem is the code GC tuning is a last resort.

GC tuning priority: First: Select the appropriate payback second GC: Select the appropriate third heap size: select the proportion of the young generation in the stack

: 1. 2. The state monitoring GC analysis, to determine whether to optimize minGC time "50ms, 10s FullGC execution time 1s at a frequency more than 10 minutes

Print GC logs:

-XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath -XLogger:logpath -XX:PrintHeapAtGC

Storage Performance Optimization

  • Try to use SSD
  • Regularly clean data or data stored separately according to the nature
  • Result set processing

This article from the "road of sophisticated back-end" original, starting in blog teckee.github.io/ , please indicate the source

Search "sophisticated back-end road of" public concern number and immediately get the latest articles and 2,000 yuan worth BATJ boutique interview courses .

The sophisticated back-end road .png

Guess you like

Origin juejin.im/post/5e5a77366fb9a07ccd518d64