Hematemesis sorting, Jmeter performance test common problems + solutions summary (detailed)


Preface

1. request request timeout setting

timeout The timeout time can be set manually. Create a new http request, find the "Timeout" setting in the "Advanced" settings, and set the connection and response time to 2000ms.

1) The requested connection timed out and the server could not be connected.

Phenomena:
The Jmeter manifestation is: the first few requests are successful, but some subsequent requests will report errors, and some requests are successful

Error 1:

Response code: Non HTTP response code: java.net.SocketTimeoutException
Response message: Non HTTP response message: connect timed out

Reason:
Generally, it is because there are too many threads and connection time out error. The server has too many requests and cannot handle them.

The time to check the Load time is greater than the connect time out time set by the request, so this exception is thrown. It may be caused by the fact that the server has many requests being processed and the processing time is long, causing jmeter to be unable to connect to the server.

Solution: Set jmeter http request timeout conn and restart the server

Error 2:

Connection timed out: connect工具
java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(

Reason:
It is mostly due to the exhaustion of port numbers. Usually the port number of a server is most likely 65535. It is recommended to use this command to check the pressure test machine and server respectively. Port usage status, netstat -nat|grep -i 8080|wc -l, if the number is around 6w, it may be that the port number is exhausted. At the same time, check the status of most ports, which should be in the time_wait status.

Solution: If the port number is exhausted for a stress testing machine, add more stress testing machines and use jmeter distributed stress testing (jmeter turns on keep_alive by default)

If you count servers and the port numbers are exhausted, the most likely reason is that the server has opened a short connection. Just change the short connection configuration into a long connection.

If the server side is a short connection, every time jmeter initiates a request, it will create a TCP three-way handshake. After the data is transmitted, the link is actually not closed. The link status is time_wait. When the next request comes, a new port will be reopened and created. TCP three-way handshake, transmitting data...

In this way, as the number of requests increases, the ports will become less and less, so the ports will be exhausted quickly, and most ports are in the time_wait state. If the server also supports long connections, then the next request will come .

Transmission will continue on the last requested channel, and the port usage will be greatly reduced, effectively avoiding the problem of port exhaustion.

For normal operation, each request can be given a timeout period to avoid http timeout errors.

2) The connection is successful, but the read times out.

If you cannot wait for the data returned by the server, it is usually because the amount of queries requested this time is large, such as checking the vertices of 5 degrees. (timeout is less than the maximum waiting time of the server) read time out error
jmeter disconnected the request before it could wait for the data returned by the server.

Response code: Non HTTP response code: java.net.SocketTimeoutException
Response message: Non HTTP response message: Read timed out

When this error occurs, jmeter is already connected to the server. Check that the load time does not exceed the set request timeout. The possible cause of the error is that the server has not processed the thread's request, or the link has been disconnected to ensure service capabilities.

In order to verify the guess, the concurrent number of requests is sent to the server for more than half an hour. After a period of time, the request receives a 503 response, confirming the guess.

3) The connection is successful and the server times out when querying data.

This is due to the server timeout mechanism caused by the request in 2. If the query time exceeds 30s, an error will be automatically reported. (timeout is greater than the server’s waiting time)

On the basis of 2, a large response time has been set, but it is still timeout. This should mean that the server has timed out when it cannot wait for the data returned by the database.

2. Problems with the press itself

1) In network programming, especially when there are too many new network connections in a short period of time, exceptions
java.net.BindException: Address already in use: JVM_Bind often occur
Java.NET.BindException: Address already in use: connect

reason:

There are too many new socket operations in a short period of time, and the socket.close() operation cannot release the bound port immediately. Instead, it sets the port to the time_wait state and releases it after a period of time (default 240s). You can see this with netstat -na , and finally the system resources are exhausted (on Windows, the pool of ephemeral ports is exhausted, this interval is between 1024-5000)

Solution:
On the machine running jmeter agent, add a registry entry

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
MaxUserPort 65334
TcpTimedWaitDelay 30

Jmeter tool running settings:

In cmd, use the regedit command to open the registry
In HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
right-click Parameters
to create a new DWORD value, (decimal ) is set to 30 seconds. Name: TcpTimedWaitDelay, value: 30. Create a new DWORD value, (decimal) the maximum number of connections is 65534. Name: MaxUserPort, value: 65534

Select decimal as the base; to increase the number of allocable tcp connection ports and reduce the lifetime of connections in the TIME_WAIT state

After modifying the configuration, remember to restart the machine for it to take effect.

jmeter returns java.net.SocketException: Connection reset
after sending the request. This indicates that there is a problem with the test server. You can go to the page to verify. It is possible to configure client settings such as the tool run settings above.

java.net.SocketException: Socket closed

step1:
Find the advanced implementation in the http request, select httpclient 4, and set the connect to 15000-300000 milliseconds.

step2:
In the bin directory of the jmeter installation directory, find jmeter.properties and open it. Open the comment on line 425 and set the value to 1:

httpclient4.retrycount = 1
httpclient4.idletimeout=<time in 1000 ms>
java.lang.OutOfMemoryError: Java heap space

Reason:
Observe the memory of the machine running jmeter. The memory usage is high and exceeds the memory upper limit set by jmeter.

Solution:
Modify the jmeter configuration file and adjust the memory available range server
Modify the /bin/jmeter.bat file: Find these 2 lines

set HEAP=-Xms256m -Xmx256m
set NEW=-XX:NewSize=128m -XX:MaxNewSize=128m

Change to:

set HEAP=-Xms1024m –Xmx2048m(最大值不能超过系统内存的1/2)
set NEW=-XX:NewSize=128m -XX:MaxNewSize=512m网络

{ "_t" : "StringResultObject", "status" : 1030, "message" : "Server error", "data" : null, "isSuccess" : false }

If you encounter the response returned by the above request, you must first go to the server-side logs and use the logs to locate the problem.

Failed to initialise remote engine java.rmi.ConnectException: Connection refused to host:

reason:

During distributed testing, there is a problem with the link between server and agent. After troubleshooting a single machine, it was found that an agent machine had multiple network cards installed. When rmi was remote, it was looking for the network card of the virtual machine, causing the link to fail.

Solution:
Disable the unused virtual machine network card and restore it after testing

java.lang.OutOfMemoryError: Java heap space

Reason:
jmeter is a pure java development tool. The memory is managed by the java virtual machine JVM. When the memory is not recycled in time and the heap memory is insufficient, a memory overflow error will be reported. .

Conceptual supplement:
Memory leak: The application does not release the resources in time after using them, resulting in unnecessary resources being held in the application memory.

Memory overflow: The application's memory can no longer meet normal usage, and the stack has reached the maximum value set by the system, leading to a crash.

It is usually due to a memory leak that causes the stack memory to continuously increase, causing a memory overflow. The same is true for jmeter. During the jmeter test, if the memory overflows, the above prompt will generally appear: java.lang.OutOfMemoryError: Java heap space means heap memory overflow and not enough.

Solution:
Knowing that the reason for the error is due to insufficient heap memory size, you will naturally think of the solution to memory overflow: adjust the heap memory size.

Steps (take Windows system as an example, Linux system is similar):
Open the jmeter.bat file, search by keyword "HEAP", and change the original configuration to the following: Modify Before:

if not defined HEAP (
rem See the unix startup file for the rationale of the following parameters,
rem including some tuning recommendations
set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m
)
)

After modification:

if not defined HEAP (
rem See the unix startup file for the rationale of the following parameters,
rem including some tuning recommendations
set HEAP=-Xms512m -Xmx4000m
set NEW=-XX:NewSize=256m -XX:MaxNewSize=512m
)

set HEAP=-Xms512m -Xmx4000m: adjust the size of the heap memory

set NEW=-XX:NewSize=256m -XX:MaxNewSize=512m: Adjust the size of the new band in the heap memory

PS:
This value is not bigger, the better. It depends on the machine used for the stress test. Generally speaking, the maximum value of heap memory should not exceed half of the physical memory, otherwise It is easy to cause jmeter to run slowly, freeze or even memory overflow (because Java's own garbage collection mechanism dynamically allocates memory, which will occupy a lot of memory when adjusting). The memory allocated by NEW should not be too large.

After the modification is completed, save it and restart JMeter to take effect.

This method of modifying the heap size is only applicable to some situations and is not omnipotent. When the number of threads to be simulated is large, distributed stress testing needs to be adopted according to the specific situation.

When running jmeter from the command line, be sure to disable listeners such as "View Result Tree" and "Aggregation Report" because it really consumes memory.

Disk monitoring tools include iostat & htop.
Network monitoring tool includes iftop.
You can use it to check the network connection statusnetstat -n | find /I "established" /c

The following is the most comprehensive software testing engineer learning knowledge architecture system diagram in 2023 that I compiled.

1. Python programming from entry to proficiency

Please add image description

2. Practical implementation of interface automation projects

Please add image description

3. Web automation project actual combat

Please add image description

4. Practical implementation of App automation project

Please add image description

5. Resumes of first-tier manufacturers

Please add image description

6. Test and develop DevOps system

Please add image description

7. Commonly used automated testing tools

Please add image description

8. JMeter performance test

Please add image description

9. Summary (little surprise at the end)

No one is perfect, we all have shortcomings and shortcomings, but the key is to dare to face these problems, humbly accept criticism and suggestions from others, constantly improve and improve ourselves, and become a better self.

Don't care too much about other people's evaluations and opinions, because that's how they see you. What you should do is focus on self-growth and improvement and become an independent and confident person.

On the road to success, we need to always maintain our thirst for knowledge, our pursuit of truth, and our curiosity about the unknown. Only in this way can we surpass ourselves and climb higher mountains.

Guess you like

Origin blog.csdn.net/shuang_waiwai/article/details/134644521