3

I'm testing Django asgi performance using two very simple views. I'm running gunicorn and uvicorn in such a manner:

gunicorn core.wsgi --workers=1 --threads=1 --access-logfile=- core.wsgi:application
uvicorn --workers 1 core.asgi:application

The views are as follows:

def simple_sync_view(request):
    usernames = "Hello World"
    return JsonResponse({'message': usernames})


async def simple_async_view(request):
    usernames = "Hello World"
    return JsonResponse({'message': usernames})

Project has no middlewares enabled. When testing using : wrk -t10 -c100 -d10s http://127.0.0.1:8000/test/sync/ synchronous server is always several times faster:

  10 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    37.42ms    7.87ms 158.35ms   98.88%
    Req/Sec   271.54     38.28   303.00     79.60%
  26885 requests in 10.01s, 4.87MB read
Requests/sec:   2685.95
Transfer/sec:    498.40KB

comparing to uvicorn:

  10 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   115.38ms   37.55ms 245.49ms   53.91%
    Req/Sec    88.65     41.14   200.00     74.63%
  8638 requests in 10.02s, 1.40MB read
Requests/sec:    862.49
Transfer/sec:    143.19KB

regardless of type of view, sync or async. So I wonder, is the Django in asgi mode so slow or what ?

MarcinSz
  • 31
  • 1

0 Answers0