I am using Locust to test the UDP server. My aim is to simulate a large number of user logins and test the load on the server. Refer to the official documentation. After reading the relevant documents, I inherited the socket class and added this code to the SendTo and recvfrom methods.
def recvfrom(self, bufsize):
recv_data = b''
start_time = time.time()
try:
recv_data, address = super(UdpSocketClient, self).recvfrom(bufsize)
except Exception as e:
total_time = int(time.time() - start_time) * 1000
events.request_failure.fire(request_type="udpsocket", name="recvfrom", response_time=total_time, exception=e)
else:
total_time = int(time.time() - start_time) * 1000
events.request_success.fire(request_type="udpsocket", name="recvfrom", response_time=total_time, response_length=0)
return recv_data, address
The running result is shown in the picture below. It seems to have no effect. Does anyone know where I am wrong?
Name # reqs # fails | Avg Min Max Median | req/s failures/s
------------------------------------------------------------------------------------------------------------------------
udpsocket recvfrom 39 0(0.00%) | 0 0 0 0 | 2.40 0.00
udpsocket sendto 39 0(0.00%) | 0 0 0 0 | 2.40 0.00
------------------------------------------------------------------------------------------------------------------------
Aggregated 78 0(0.00%) | 0 0 0 0 | 4.80 0.00
English is not my mother tongue, please forgive my grammatical mistakes.
Thank you for reading and look forward to your answers!