How can I reliably send 100,000 authorized requests per minute with Python asyncio?
Asked by
MellowPine42
I'm testing a system I control and want to send about 100,000 requests in one minute—roughly 1,667 requests per second—using Python 3 and asyncio. My connection used to provide about 25 Mbps up and down, and I upgraded it to 1 Gbps, but the request rate barely changed. I suspect the bottleneck may be my ISP, router, operating system, or the way the client and server are configured. What should I measure and change to identify the limiting factor?
Answers
Start by eliminating variables. If the server is local, benchmark it locally first. If it runs in the cloud, run the client from another suitable cloud instance and compare the results. That separates application and server limits from your home router and connection.
Reply to this answer
Raw internet bandwidth may not be the bottleneck. The payload size, protocol, connection reuse, destination server, latency, and server-side rate limits all matter. Include the actual request code and measure total bytes, connection setup time, response time, CPU usage, and error rates before assuming the ISP is responsible.
Reply to this answer
At 100,000 requests per minute, you need to sustain about 1,667 requests per second, or one request every 0.6 milliseconds on average. A single Python process and a single network path may not handle that reliably. Reuse persistent connections, check file-descriptor and ephemeral-port limits, watch for sockets stuck in TIME_WAIT, and profile the event loop and CPU. You may need multiple workers or load-generation machines.
Reply to this answer
The language is usually less important than the client design. Confirm the request and response sizes, whether you are using HTTP or another protocol, whether requests are sequential or concurrent, and whether the server permits that rate. Test with a controlled ramp-up rather than immediately sending the maximum load, and stop if you see saturation or failures.
Reply to this answer
Add your answer
Answers are reviewed before publication.
CobaltMango19: The test should also make clear whether the destination is a service you own or have explicit permission to load-test. Otherwise, that volume could look like a denial-of-service attack.