[Frequently asked questions about performance testing and precautions before stress testing] Super detailed! ! !

Performance testing tips

1. Evaluate the maximum concurrency allowed under the current broadband:

For example, if the response size of a webpage request is 120K, and the server bandwidth is 100M, then it can support about 80 concurrency (the calculation method is: 100×1024÷8×75%÷120=80),

The division by 8 is because the unit of broadband and file size is different. The unit of broadband is bit, and the unit of file is Byte (1Byte=8bit). The reason for multiplying by 0.75 is that, in order to ensure normal server access,

It is necessary to reserve a certain amount of bandwidth, which cannot be calculated according to the maximum value.

2. Effectively test the concurrency calculation of a single machine (a single machine supports a maximum concurrency of 546/s, so under normal circumstances, the concurrency should be within 500):

① Theoretically, the number of ports in a system is 65536

② When the client initiates a request, the system will allocate an idle port for use, and a port can only be used by one service at the same time

③ It takes about 2 minutes for a tcp protocol to completely release the port from disconnection to the system

Combining the above three items, we can calculate:

Theoretically, for a single test machine, the maximum effective number of concurrency supported by performance testing per second is: 546=65536/2/60, except that the system itself occupies part of the interface, so the number of concurrency should be controlled within 500

3. Performance test N+1 method:

The so-called N+1 method means that during the performance test, an idle machine can be added outside the stress test machine to manually send the request during the stress test, where N is the request of the stress test machine,

1 is the request sent by an idle machine, so that the test can be more appropriate to the user experience when the concurrency is high, and it is easy to find some problems.

4. 125 principles:

That is, the time from when the client sends a request to when the server responds and completes the acceptance:

Within 1S, the user will feel that the system responds quickly and the experience is very good;

Within 2S-5S, the user will feel that the response speed of the system is not bad;

If it is above 5S, the user will feel that the system response is very slow, the experience is poor, and the user is easy to miss the page.

Analysis of common connection errors during performance stress testing

1. An error is reported during the pressure test: the connection timed out (ConnectTimeout)

cause:

1) It may be caused by the connection timeout setting of the pressure measurement tool itself

a) For example, on the Jmeter http request page, the advanced tab, there is a timeout setting, which can set the timeout for sending and returning requests, such as setting both the connect and response terminals to 30 000 (30s);

b), such as in Jmeter's jmeter.properties: httpclient4.idletimeout = 30000 (delay 30 s, generally set to 10 - 60 s)

2. There may be a connection timeout problem on the server side

a), first analyze the data link of the pressure test interface

b) Analyze the possible connection timeouts of each layer step by step according to the links, such as Nginx, mq, redis, microservices, and databases, each layer may have connection timeouts

2. An error is reported during the stress test: Connection refused

1), first check the network and server status, and exclude physical connection problems

2) When high concurrency, some interfaces will limit the flow operation, and some requests can be limited in the intervention layer Nginx (nginx_http_limit_conn_Module), and then the request connection is rejected

3) Some middleware, such as Tomcat, has a maximum waiting count setting, such as accept-count value. acceptCount is the maximum number of waits that can be accepted. When the waiting queue is full, a new request will be rejected by Tomcat.

4) For databases, such as mysql, mongoDB, etc., there is a maximum number of connections. If the request exceeds the maximum number of connections, the request will also be rejected.

3. An error is reported during the pressure test: the connection is reset (Connection reset)

1) In the actual pressure test, the author encountered the situation that the connection was reset. Later, it was found that there was a problem with the domain name of the pressure test network.

2) It may be that the server and the client have different connection methods, and the same connection method such as long connection or short connection needs to be used at the same time.

3), HTTPS protocol, there may be inconsistencies in the TLS version, the server and the client use the same TSL version

4. An error is reported during the pressure test: Socket closed

1) Reason analysis: The number of connections on the Linux server is 1024 by default, which is too small, which is obviously not enough for high concurrency

Modify three parameters vim /etc/sysctl.conf

net.ipv4.ip_local_port_range = 1024 65535

net.ipv4.tcp_tw_recycle = 1

net.ipv4.tcp_tw_reuse = 1

Modified sysctl -p

5. When using Jmeter to do a stress test under windows, an error is reported: java.net.BindException: Address already in use: connect.

Reason: The ports provided by windows for TCP/IP connections are 1024-5000, and it takes 3-5 minutes to recycle them, which will cause us to fill up the ports when we run a large number of requests in a short period of time, resulting in the above error.

Solution (operate on the server where jmeter is located):

1), enter the regedit command in cmd to open the registry;

2) Right-click Parameters in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters;

3), add a new DWORD named MaxUserPort;

4), then double-click MaxUserPort, input the value data as: 65534, choose decimal as the base; (increase the port number more)

5) After completing the above operations, be sure to restart the machine for the configuration to take effect

Guess you like

Origin blog.csdn.net/m0_43550804/article/details/132336455