First open three terminals, then (wait for the 1st to be running before attempting 2 and 3):
If you do not wish to use docker, simply use the second lines only.
-
docker container run -it -v $PWD:/app -w /app --name testcase-1821 --rm python:3.5 \ sh -c 'sh setup.sh; python3 server.py'
-
docker container exec -it testcase-1821 \ watch -n 0.1 'netstat -npt | grep $(pgrep python | tail -n1) | wc -l'
-
docker container exec -it testcase-1821 \ python3 client.py
While 3
is running you should see a connection count every 100 requests
together with the current # of connections in 2
. 3
will first run 10000
reqs using the limit
in aiohttp, and then another 10000 reqs using
asyncio.Semaphore
to limit requests.
At the time of writting, using limit see connections drop dramatically at some point during the last 3000 requests. Very occasionally this will not happen, but a second attempt nearly always shows the connection drop. Conversely, using the semaphore approach consistently maintains connection levels and finishes much faster.