After 3 years of Java outsourcing, Ali passed the test internally, but in the end it fell on the tuning experience!

foreword

In the current era, understanding high-concurrency performance tuning must be a plus for you to become awesome on the technical advancement track. It doesn't matter whether you are in a development, architecture or management position, or other Internet-related positions. Because it is no exaggeration to say that in the current environment of concurrent traffic of tens of millions of levels, if you understand concurrent pressure testing, performance bottleneck diagnosis, optimization solutions, and architecture evolution, you will gain high salary, voice, sense of accomplishment, and irreplaceability at the same time .

Performance optimization needs to be combined with scientific working methods according to business scenarios, and reasonable optimization can greatly improve production efficiency. Today, understanding high-performance tuning means that you can directly empower the company's business. In short, it brings benefits to the company.

However, many people have encountered the following misunderstandings in the process of learning tuning:

  • I have seen tuning-related knowledge points on the Internet, but I have never practiced it, so I forget it after reading it;

  • When working, redis, kafka, etc. are all called directly, and if there is a problem, you will be at a loss;

  • I thought that tuning is just adjusting a parameter, and the focus is on optimizing the code.

  • The interviewer asked about tuning experience, but he has never actually done it.

  • When encountering high-concurrency production problems, machines and configurations are added, but there is no good solution.

If these problems are not clear, there is a high probability that you will stay up late and work overtime every day, and repeat CRUD. On the contrary, if you know how to tune high-concurrency performance, you can become a firefighting captain in the actual production environment, and solve the bottleneck problem of tens of millions of scale projects with one person, and the sense of growth you get may be far greater than the salary. your satisfaction.

Therefore, if you want to go further and wider in the workplace, it is definitely an excellent choice to thoroughly understand high concurrency tuning.

Now when I go to an Internet company for an interview, the interviewer will throw a bunch of online system scenario questions at every turn:

  • The CPU, IO, and memory of the online system are suddenly full, and the interface response time is too long

  • The slow execution of SQL in the online system causes the system interface to time out

  • Deadlock caused by high concurrency of online database Mysql

  • The online database Mysql is inexplicably jittering and cannot be located

  • The online system suddenly freezes and cannot be accessed, and frequently receives GC alarms

  • The online system suddenly overflows OOM memory, and the memory leak cannot be located

  • The online production environment does not know how to set various parameters of the JVM

  • I don’t know how to optimize the performance of ultra-high concurrent systems

How many scene problems can you solve after reading it?

Most people are always confused when they encounter these performance problems. Many students try to browse blogs or read books online, but find it almost difficult to find a suitable solution.

Of course, some students have a small-scale system and have not encountered similar problems, but when they are asked similar practical questions during job-hopping interviews, they can only spread their hands. .

In fact, Java performance tuning is not a programming language, and it cannot be mastered and applied through straight-line thinking. It's not that you can't learn it, but that you haven't figured out the underlying principles and lack practical combat and experience!

study notes

I recommend a study note of "JVM and Performance Tuning" inside Ant Financial. There are 5 parts in total, which have been organized into PDF documents.

Pay attention to the official account: programmer chasing the wind, reply [0206] to obtain the above information

### 1. JVM memory area division

1. Program counter (thread private)

2. Java stack (thread private)

3. Local method stack (thread private)

4. Heap (thread sharing)

5. Method area (thread sharing)

6. Direct memory (thread sharing)

###2. JVM Execution Subsystem

1. Class class file structure

1.1 Java cross-platform basis

1.2 The nature of the Class class

2. Bytecode instructions

2.1 Load and store instructions

2.2 Operation or Arithmetic Instructions

2.3 Type Conversion Instructions

2.4 Instructions for creating class instances

2.5 Instructions for creating arrays

2.6 Access Field Instructions

2.7 Array access related instructions

2.8 Instructions to check class instance type

2.9 Operand Stack Management Instructions

2.10 Control Transfer Instructions

2.11 Method call instruction

2.12 Method Return Instructions

2.13 Exception Handling Instructions

2.14 Synchronous commands

3. Class loading mechanism

4. Class loader

4.1 System class loader

4.2 Parental delegation model

5. Tomcat class loading mechanism.

6. Method call details

6.1 Analysis

6.2 Static dispatch

6.3 Dynamic dispatch

6.4 Stack-based bytecode interpretation and execution engine

###3. Garbage collector and memory allocation strategy

1. Is value passing or reference passing in Java?

2. Reference type

3. Basic garbage collection algorithm

3.1 According to the basic recycling strategy

3.2 According to the method of partition treatment

3.3 By system thread

4. Dispose of garbage by generation

5. Types of Garbage Collection GC in JAVA

###4. Write efficient and elegant Java programs

1. Object-oriented

1.1 What should I do if there are too many constructor parameters?

1.2 Classes that do not need to be instantiated should have private constructors

1.3 Do not create unnecessary objects

1.4 Avoid finalizers.

1.5 Minimize class and member accessibility

1.6 Minimize variability

1.7 Composition over inheritance

1.8 Interfaces are better than abstract classes

2. Method

2.1 Variable parameters should be used with caution.

2.2 Return a zero-length array or collection, do not return null

2.3 Prefer standard exceptions

3. General programming

i

### Five, performance optimization

1. Commonly used performance evaluation/test indicators

1.1 Response time

1.2 Concurrency

1.3 Throughput

1.4 Relationship

2. Common performance optimization methods

2.1 Avoid premature optimization

2.2 Conduct system performance test

2.3 Find system bottlenecks, divide and conquer, and gradually optimize

2.4 Common means of front-end optimization

3 Application service performance optimization

3.1 Caching

3.1.1 The basic principle and essence of caching

3.1.2 Guidelines for Proper Use of Buffers

3.1.3 Distributed cache and consistent hashing

3.2 Asynchronous

3.2.1 Synchronous and asynchronous, blocking and non-blocking

3.2.2 Common asynchronous means

3.3 Cluster

3.4 Application related

3.4.1 Code level

3.4.2 Concurrent programming

3.4.3 Reuse of resources

3.4.4 JVM

3.4.5 GC tuning.

3.4.6 Tuning in practice

3.4.7 Storage performance optimization

The knowledge points about JVM and performance tuning summarize a mind map and analyze it for everyone

Some common JVM and tuning interview questions

1. Talk about the JVM memory area

2. How to get the memory used by the Java program? % of heap usage?

3. What is the difference between heap and stack in Java?

4. Describe the principle mechanism of JVM loading class files

5. What is GC? Why is there a GC?

6. When will FullGC be triggered

7. Briefly describe the object structure of Java

8. How to judge that the object can be recycled

9. Will garbage collection occur in the permanent generation of the JVM?

10. Garbage collection algorithm

11. What are the tuning commands?

12. Tuning tools

13. When do Minor GC and Full GC occur respectively?

14. What JVM performance tuning do you know

15. Can you guarantee GC execution?

Answers to these common JVM and performance tuning interview questions are organized into PDF documents.

The JVM and performance tuning study notes mentioned in the article + JVM and performance tuning interview questions summary + JVM and performance tuning mind map can be shared with you:

Pay attention to the official account: programmer chasing the wind, reply [0206] to obtain the above information

Summarize

If you want to apply performance tuning methods to business, theory is very important. It is more important to be able to apply theory to business scenarios, and it is more important to have real scenarios and data for you to practice and give feedback. A good performance tuning solution is not achieved overnight. From analyzing logs to locating bottlenecks, specific theoretical analysis and practical operations are required.

Guess you like

Origin blog.csdn.net/Design407/article/details/110953891