System Performance Tuning (6) ---- looking for performance bottlenecks

Source: Internet
Author: User

I have optimized the performance of a system recently. I hope it will be useful to you. Let's talk about the general business and optimization results (this is not a show off, but here we should have a round of applause. Ah, self-entertainment is a kind of disease, and it is strange that I gave up treatment ).

When processing N users at the same time, each user needs to perform corresponding operations according to different conditions. Here, the operation may be to update other tables, or insert other tables to determine based on the user's status. Of course, N here is not all users, it is a List based on the joint query. It should be noted that this query statement has been optimized by our predecessors, so the optimization of the query is not within the scope of consideration.

Speaking of performance optimization, It is accurate to say that the underlying performance optimization is nothing more than modifying SQL statements or adding indexes without indexes in JPQL. As long as the cause is found, modifying the code is definitely not a problem, just like the song "an old man draws a circle in the South China Sea", it is easy to do things after the circle is finished, the difficulty is where to draw the circle. The following is the story of the same circle:

When a large motor of Ford was faulty, all engineers were helpless. Finally, a German engineer was invited. He walked around the motor several times, listened to the sound, then drew a circle on the motor with chalk, said to everyone, "Open, reduce the coil here by 16 ". As a result, the fault is eliminated. Afterwards, German engineers demanded a compensation of $30 thousand. Why is the price of drawing a circle so high? German engineers replied, drawing a circle for $1 and knowing where to draw a circle for $29999.

How to discover performance bottlenecks

1. Test Data as authentic as possible

Second: test data as authentic as possible

Third: refer to the above two points

Why do we say this? In this optimization, the data volume was 15 million. Considering the time problem, I wanted to steal a lazy and create millions of data records, no problems were found after running the results several times. As for the reason for laziness, I comforted myself so much. "Even if a database is inserted using a stored procedure, it takes a lot of time to insert millions of data records, in addition, the data is basically used up and has to be recreated (well, I admit that my level is low, please kindly advise me How to quickly create data) "for various reasons. I still cannot do anything in two days, as described in ordinary detective novels, "cases" were once deadlocked before the deadline and finally forced to use production data for testing.

Do not ignore any clues

The first time I tested production data, I only focused on errors in the background logs. I didn't put any warning in my eyes, let alone info (it turns out that info is actually useless) later, when I checked the logs, I found the warning log. It turns out that the connection pool is full. The default value of Glassfish is 32, which means it runs stably after being changed to 320, and the total time has increased from more than 50 minutes to six minutes. In fact, I know that this number needs to be adjusted step by step. It guides you to adjust it to an optimal value, which neither wastes memory nor ensures system efficiency. Performance optimization is hard to say, simple, and simple. It's as simple as drawing a circle more than before. It's hard for you to know where the problem is before solving the problem.

(Lend me a pair of eye breaks $ _ $)

"Happy families are similar. Unfortunately, different families are different." The same is true for systems. "High-performance systems are similar, low-performance systems have their own bottlenecks ". This optimization is only the tip of the iceberg of the system optimization technique, but the optimization idea is generic. Find out the bottleneck ---- solve the bottleneck, therefore, the ability to locate a problem is more valuable than the ability to solve the problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.