day92-performance stress test-optimization-the impact of middleware on performance

1. Purpose

Understand the impact of middleware on the performance of requests

2. Process awareness

First of all, we must be clear about the process for us to visit the homepage and obtain the data

Because we added the local mapping as follows, visiting  http://gulimall.com/  is equivalent to visiting the 80 port of the virtual machine 192.168.56.10, we added the virtual machine 80 port monitoring in nginx before

Load balance to the upstream server-"Gateway, then the gateway host is routed to the homepage of the commodity service, detailed steps refer to the link

https://blog.csdn.net/JavaCoder_juejue/article/details/112858021?spm=1001.2014.3001.5501

3. Stress test nginx

(1) Add thread group

50 threads per second, always access

 (2) Add http request

And add the listener

Result tree, summary report, aggregate report

 (3) docker stats View cpu usage, memory usage, maximum memory, memory usage, network io and other parameter changes, and it will be dynamically refreshed every second

After starting the thread group, at some point

 

It can be seen that nginx is cpu-intensive, and it is enough to receive requests from multiple threads to process, without creating objects, so it occupies less memory, but after processing the request and switching between different threads and returning the result after processing the request

Need to occupy cpu, so it is cpu intensive

Close the test, see some exceptions, it’s okay, that is because some requests have not been processed, and the connection is closed.

According to the aggregate report

Create a table to organize the performance-related information displayed by the Nginx pressure test

 

4. Stress test gateway

http://localhost:88/

The request to access the gateway, but there is no home page, so 404, you can use this to stress test

 After starting jvisualvm, you can see that it does not occupy much memory, it is cpu-intensive, similar to nginx

Looking at the garbage collection part again, because the Eden Park is very small, minor gc occurs frequently. At this time, I was thinking that increasing the memory size of the Eden Park can reduce the number of minor gc and improve throughput.

According to the aggregate report, fill in the table data

It can be seen that the efficiency of our middleware alone is quite high

 

5. Simple service of pressure test

Create a simple method that simply returns a string

Test visit is successful

Add tabular data based on aggregate report

Found that the performance is still good

6. Pressure test gateway + simple service

Add route

Access test succeeded

Pressure test, you can see that the throughput has been significantly reduced

Add to table

Analyze the reasons. Assuming that a request originally sent the browser directly to the service for 10ms, it now takes 10ms to reach the gateway first, which is related to doubling the time, so the throughput will naturally also be doubled.

So how to optimize it?

1. Improve the throughput of middleware

2. Improve transmission efficiency, such as buying better network cables, network cards, and using more efficient transmission protocols

7. Pressure test full link (that is, nginx+gateway+simple service)

Why can the following request be tested? I won’t say much here, I will understand after reading the previous one.

Stress test

Add tabular data according to the report

You can see that the throughput goes down a lot

The above is just a simple request for testing, and the actual business request will be tested later and an optimization plan will be given

Guess you like

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