day93-performance stress test-optimization-simple optimization throughput test (adjust log level, open thymeleaf template, add index)

Now the pressure test to visit the homepage alone does not go through the request of the middleware

1. Pressure test to obtain first-level classification

Still add thread group as before, add http request

After running stable for a period of time, view the aggregate report

Fill out the form based on the aggregate report

Open jvisualvm and found that minor gc is very frequent because of the small memory of Eden Park, which greatly affects efficiency

2. Pressure test to obtain all three-level classification data

Add http request

View aggregate report

Fill in the form, the response time here is a bit outrageous, the response time is a reference, mainly depends on the throughput, if you use another machine to pressure test, the result data will be standard, here is only for reference to find the problem.

3. Pressure test to get all the contents of the homepage (in addition to the first level classification, it also includes the static resources of the page)

Under the following settings in advanced

Add http request, the same as the first-level classification of stress testing

View aggregate report

Fill out the form

4. Think about the optimization plan

In the previous article, you can clearly see the impact of middleware on performance. Now I list the points that cause performance loss that I have learned for so long under the pressure test.

(1) Middleware: The more middleware, the greater the performance loss, which is wasted on network interaction

(2)db: Needless to say this

(3) tymeleaf: the rendering speed of the template

(4) Static resources: Static resources are still placed in the project, and a request must also be sent to tomcat to obtain

5. Hands-on

(1) tymeleaf template cache is turned on

tymeleaf template caching was previously closed, now open

Do not acquire static resources

Test again

Compared with before, the throughput has increased by dozens

It was more than 230 before, now it is around 290

(2) Database optimization

Adjust log level, add index

Every database query before will be printed out, that is local, put the environment and change it to the error level

After changing

To add an index, we use the parent_cid field to query the first-level classification

Add calculation query time

    @Override
    public List<CategoryEntity> findCatelog1s() {
        long l = System.currentTimeMillis();
        List<CategoryEntity> categoryEntities = this.list(new QueryWrapper<CategoryEntity>().eq("parent_cid", 0));
        System.out.println("消耗时间:"+(System.currentTimeMillis()-l));
        return categoryEntities;
    }

Add index

Before adding an index

After adding the index, it is still a lot faster on average.

 

6. Optimized pressure test

I opened the tymeleaf cache above, adjusted the log level to error and added the index, and then re-tested the previous request.

First class classification

Three-level classification

Full data (first level classification + static resources)

Fill out the form

It is found that in addition to the acquisition of the full amount of data, the performance of other requests has been significantly improved, why, the request for static resources is still through tomcat

This involves the separation of dynamic and static nginx in the next article.

 

 

 

Guess you like

Origin blog.csdn.net/JavaCoder_juejue/article/details/113591070