Switch to a better ASGI runner
We currently use daphne as our ASGI runner, but we've had various scalability (e.g. #811) and deadlock (e.g. #1139 (closed)) problems over the years with it.
I've been researching a switch to uvicorn, running as a gunicorn worker since this is uvicorn's recommendation for production setups. I'm seeing much more effective CPU usage with this.
daphne:
$ hey -n 1000 http://bookworm-debusine-apt-mirror.incus/
Summary:
Total: 11.4065 secs
Slowest: 0.7587 secs
Fastest: 0.3110 secs
Average: 0.5658 secs
Requests/sec: 87.6694
Response time histogram:
0.311 [1] |
0.356 [6] |■
0.401 [12] |■■
0.445 [21] |■■■
0.490 [57] |■■■■■■■
0.535 [318] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
0.580 [120] |■■■■■■■■■■■■■■■
0.624 [193] |■■■■■■■■■■■■■■■■■■■■■■■■
0.669 [237] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
0.714 [22] |■■■
0.759 [13] |■■
Latency distribution:
10% in 0.4906 secs
25% in 0.5154 secs
50% in 0.5534 secs
75% in 0.6273 secs
90% in 0.6465 secs
95% in 0.6616 secs
99% in 0.7229 secs
Details (average, fastest, slowest):
DNS+dialup: 0.0002 secs, 0.3110 secs, 0.7587 secs
DNS-lookup: 0.0001 secs, 0.0000 secs, 0.0038 secs
req write: 0.0000 secs, 0.0000 secs, 0.0003 secs
resp wait: 0.5655 secs, 0.3109 secs, 0.7551 secs
resp read: 0.0001 secs, 0.0001 secs, 0.0005 secs
Status code distribution:
[200] 1000 responses
uvicorn+gunicorn:
$ hey -n 1000 http://bookworm-debusine-apt-mirror.incus/
Summary:
Total: 2.3800 secs
Slowest: 0.2920 secs
Fastest: 0.0168 secs
Average: 0.1132 secs
Requests/sec: 420.1747
Response time histogram:
0.017 [1] |
0.044 [38] |■■■■■■
0.072 [121] |■■■■■■■■■■■■■■■■■■■
0.099 [251] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
0.127 [242] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
0.154 [190] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
0.182 [94] |■■■■■■■■■■■■■■■
0.209 [42] |■■■■■■■
0.237 [10] |■■
0.264 [5] |■
0.292 [6] |■
Latency distribution:
10% in 0.0613 secs
25% in 0.0832 secs
50% in 0.1083 secs
75% in 0.1400 secs
90% in 0.1721 secs
95% in 0.1907 secs
99% in 0.2539 secs
Details (average, fastest, slowest):
DNS+dialup: 0.0002 secs, 0.0168 secs, 0.2920 secs
DNS-lookup: 0.0002 secs, 0.0000 secs, 0.0095 secs
req write: 0.0001 secs, 0.0000 secs, 0.0066 secs
resp wait: 0.1127 secs, 0.0167 secs, 0.2918 secs
resp read: 0.0002 secs, 0.0001 secs, 0.0055 secs
Status code distribution:
[200] 1000 responses