python 3.6, postgres, pip install aiohttp uvloop ujson asyncpg sanic
➤ wrk -d 10 -c 100 -t 12 --timeout 8 http://localhost:8000 # aiohttp
Running 10s test @ http://localhost:8000
12 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 13.52ms 1.58ms 43.44ms 93.29%
Req/Sec 594.37 48.42 646.00 81.33%
71051 requests in 10.01s, 11.32MB read
Requests/sec: 7099.30
Transfer/sec: 1.13MB
➤ wrk -d 10 -c 100 -t 12 --timeout 8 http://localhost:8000/db # aiohttp
Running 10s test @ http://localhost:8000/db
12 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 27.43ms 6.93ms 151.69ms 97.44%
Req/Sec 296.99 24.29 340.00 87.14%
35327 requests in 10.01s, 6.46MB read
Requests/sec: 3528.96
Transfer/sec: 661.25KB
➤ wrk -d 10 -c 100 -t 12 --timeout 8 http://localhost:8000 # sanic
Running 10s test @ http://localhost:8000
12 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 4.55ms 724.50us 17.67ms 94.63%
Req/Sec 1.77k 499.35 18.67k 98.92%
211459 requests in 10.10s, 27.43MB read
Requests/sec: 20936.08
Transfer/sec: 2.72MB
➤ wrk -d 10 -c 100 -t 12 --timeout 8 http://localhost:8000/db # sanic
Running 10s test @ http://localhost:8000/db
12 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 16.98ms 6.05ms 124.18ms 98.70%
Req/Sec 483.90 40.57 540.00 94.46%
57605 requests in 10.01s, 8.82MB read
Requests/sec: 5755.33
Transfer/sec: 0.88MB
According to aiohttp documentation run_app() uses simple blocking API, so it's not async:
https://docs.aiohttp.org/en/stable/web_advanced.html#application-runners
In order to start it asynchronously you need to use AppRunner or ServerRunner:
https://docs.aiohttp.org/en/stable/web_reference.html#aiohttp.web.AppRunner