Instantly share code, notes, and snippets.

Embed
What would you like to do?
Initial benchmark comparisons of ASGI (uvicorn) and WSGI (gunicorn)

Please note:

A more fair comparison is here with gunicorn using the meinheld worker https://gist.github.com/erm/975e9a8dda60d94823dc5f8a8d354b57.

Also, these benchmarks were run against an experimental fork of Django and the testing conditions are not ideal. They aren't intended to be a conclusive measure of the performance differences between ASGI/WSGI. Proper benchmarks to come later.

Test project:

https://github.com/erm/django-async-tests

uvicorn (ASGI)

Running: uvicorn asgiproj.asgi:application -b 127.0.0.1:8001

[erm@fezzan ~]$ wrk -d20s -t10 -c200 http://127.0.0.1:8001/asgi/
Running 20s test @ http://127.0.0.1:8001/asgi/
  10 threads and 200 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    28.68ms   10.16ms  69.46ms   76.20%
    Req/Sec   700.81    130.10     4.79k    82.43%
  139697 requests in 20.10s, 19.32MB read
  Socket errors: connect 0, read 78, write 0, timeout 0
Requests/sec:   6949.09
Transfer/sec:      0.96MB

gunicorn (WSGI)

Running: gunicorn asgiproj.wsgi:application -b 127.0.0.1:8001

[erm@fezzan ~]$ wrk -d20s -t10 -c200 http://127.0.0.1:8001/wsgi/
Running 20s test @ http://127.0.0.1:8001/wsgi/
  10 threads and 200 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   115.78ms    9.45ms 170.10ms   87.99%
    Req/Sec   109.18     27.44   190.00     67.76%
  16432 requests in 20.10s, 2.98MB read
  Socket errors: connect 91, read 1145, write 22, timeout 0
Requests/sec:    817.51
Transfer/sec:    151.69KB
@ChillarAnand

This comment has been minimized.

ChillarAnand commented Jun 18, 2018

These views hello world views. It is interesting to note that asgi is 8x faster than wsgi. Need to see how this works on actual crud apps with db calls.

@babu-upcomer

This comment has been minimized.

babu-upcomer commented Sep 17, 2018

Yes, can uvicorn be able to do non blocking db calls? Like gevent db pools?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment