[Django] #32773: Production Configuration of Django 3.2 with gunicorn and uvicorn

16 views
Skip to first unread message

Django

unread,
May 21, 2021, 1:54:18 PM5/21/21
to django-...@googlegroups.com
#32773: Production Configuration of Django 3.2 with gunicorn and uvicorn
------------------------------------------------+------------------------
Reporter: allen-munsch | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
Hoping for a bit of guidance here.

How can I contribute to the documentation of using django ASGI in a
production environment?

Also, Any suggestions on tuning these things for relatively the same
performance?

Current settings ( seems to perform at about the same )
py3.8.10
django3.2
gunicorn with 18 workers using uvicorn.UvicornWorker
9 heroku Performance L instances

Previously
py3.6.13
django2.2.5
gunicorn with 10 workers using eventlet
7 heroku Performance L instances

However, notice the two instance difference is quite a bit extra in cost.

wrote out a thing to roughly benchmark django and fastapi being part of
the same ASGI app.

https://github.com/allen-munsch/benchmark-django-fastapi/

Specifically trying to determine upgrading from django 2.2.5 to django 3.2
and layering in FastAPI and running it in a production environment.

Anyone here have any advice on doing that?

https://github.com/allen-munsch/benchmark-django-
fastapi/blob/main/docker/web/docker-asgi-with-static-entrypoint.sh
https://github.com/allen-munsch/benchmark-django-
fastapi/blob/main/testdjango/asgi_with_static.py

I was thinking these but with gunicorn --workers 18 .... on 14 heroku
Performance L instances, and scaling down to 7

https://devcenter.heroku.com/articles/dyno-types

seems like django 3.2 served with uvicorn under peak load is twice as slow
in a production environment ...
pretty spiky to 4x slower in comparison to using gunicorn and eventlet
with the same number of web workers ( 7 heroku Performance L )

--
Ticket URL: <https://code.djangoproject.com/ticket/32773>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 21, 2021, 1:58:47 PM5/21/21
to django-...@googlegroups.com
#32773: Production Configuration of Django 3.2 with gunicorn and uvicorn
-------------------------------------+-------------------------------------
Reporter: allen-munsch | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 3.2
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by allen-munsch):

* Attachment "Screenshot from 2021-05-21 12-56-13.png" added.

picture of performance metrics compared to last week

Django

unread,
May 21, 2021, 1:59:35 PM5/21/21
to django-...@googlegroups.com
#32773: Production Configuration of Django 3.2 with gunicorn and uvicorn
-------------------------------------+-------------------------------------
Reporter: allen-munsch | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 3.2
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by allen-munsch:

Old description:

New description:

Hoping for a bit of guidance here.

How can I contribute to the documentation of using django ASGI in a
production environment?

Also, Any suggestions on tuning these things for relatively the same
performance?

Current settings ( seems to perform at about the same )
py3.8.10
django3.2
gunicorn with 18 workers using uvicorn.UvicornWorker

10 heroku Performance L instances

Previously
py3.6.13
django2.2.5
gunicorn with 10 workers using eventlet
7 heroku Performance L instances

However, notice the two instance difference is quite a bit extra in cost.

wrote out a thing to roughly benchmark django and fastapi being part of
the same ASGI app.

https://github.com/allen-munsch/benchmark-django-fastapi/

Specifically trying to determine upgrading from django 2.2.5 to django 3.2
and layering in FastAPI and running it in a production environment.

Anyone here have any advice on doing that?

https://github.com/allen-munsch/benchmark-django-
fastapi/blob/main/docker/web/docker-asgi-with-static-entrypoint.sh
https://github.com/allen-munsch/benchmark-django-
fastapi/blob/main/testdjango/asgi_with_static.py

I was thinking these but with gunicorn --workers 18 .... on 14 heroku
Performance L instances, and scaling down to 7

https://devcenter.heroku.com/articles/dyno-types

seems like django 3.2 served with uvicorn under peak load is twice as slow
in a production environment ...
pretty spiky to 4x slower in comparison to using gunicorn and eventlet
with the same number of web workers ( 7 heroku Performance L )

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32773#comment:1>

Django

unread,
May 21, 2021, 2:00:08 PM5/21/21
to django-...@googlegroups.com
#32773: Production Configuration of Django 3.2 with gunicorn and uvicorn
-------------------------------------+-------------------------------------
Reporter: allen-munsch | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Old description:

> Hoping for a bit of guidance here.
>
> How can I contribute to the documentation of using django ASGI in a
> production environment?
>
> Also, Any suggestions on tuning these things for relatively the same
> performance?
>
> Current settings ( seems to perform at about the same )
> py3.8.10
> django3.2
> gunicorn with 18 workers using uvicorn.UvicornWorker

> 10 heroku Performance L instances


>
> Previously
> py3.6.13
> django2.2.5
> gunicorn with 10 workers using eventlet
> 7 heroku Performance L instances
>
> However, notice the two instance difference is quite a bit extra in cost.
>
> wrote out a thing to roughly benchmark django and fastapi being part of
> the same ASGI app.
>
> https://github.com/allen-munsch/benchmark-django-fastapi/
>
> Specifically trying to determine upgrading from django 2.2.5 to django
> 3.2 and layering in FastAPI and running it in a production environment.
>
> Anyone here have any advice on doing that?
>
> https://github.com/allen-munsch/benchmark-django-
> fastapi/blob/main/docker/web/docker-asgi-with-static-entrypoint.sh
> https://github.com/allen-munsch/benchmark-django-
> fastapi/blob/main/testdjango/asgi_with_static.py
>
> I was thinking these but with gunicorn --workers 18 .... on 14 heroku
> Performance L instances, and scaling down to 7
>
> https://devcenter.heroku.com/articles/dyno-types
>
> seems like django 3.2 served with uvicorn under peak load is twice as
> slow in a production environment ...
> pretty spiky to 4x slower in comparison to using gunicorn and eventlet
> with the same number of web workers ( 7 heroku Performance L )

New description:

https://github.com/allen-munsch/benchmark-django-fastapi/

https://devcenter.heroku.com/articles/dyno-types

--

Comment:

Ticket description contains a lot of support questions. Please use one of
[https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels
support channels].

--
Ticket URL: <https://code.djangoproject.com/ticket/32773#comment:2>

Django

unread,
May 21, 2021, 2:54:21 PM5/21/21
to django-...@googlegroups.com
#32773: Production Configuration of Django 3.2 with gunicorn and uvicorn
-------------------------------------+-------------------------------------
Reporter: allen-munsch | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by allen-munsch:

Old description:

> Hoping for a bit of guidance here.

New description:

Hoping for a bit of guidance here.

How can I contribute to the documentation of using django ASGI in a
production environment?

Also, Any suggestions on tuning these things for relatively the same
performance?

Current settings ( seems to perform at about the same )
py3.8.10
django3.2
gunicorn with 18 workers using uvicorn.UvicornWorker

10 heroku Performance L instances

Previously
py3.6.13
django2.2.5
gunicorn with 10 workers using eventlet
7 heroku Performance L instances

However, notice the two instance difference is quite a bit extra in cost.

wrote out a thing to roughly benchmark django and fastapi being part of
the same ASGI app.

https://github.com/allen-munsch/benchmark-django-fastapi/

Specifically trying to determine upgrading from django 2.2.5 to django 3.2
and layering in FastAPI and running it in a production environment.

Anyone here have any advice on doing that?

https://github.com/allen-munsch/benchmark-django-
fastapi/blob/main/docker/web/docker-asgi-with-static-entrypoint.sh
https://github.com/allen-munsch/benchmark-django-
fastapi/blob/main/testdjango/asgi_with_static.py

I was thinking these but with gunicorn --workers 18 .... on 14 heroku
Performance L instances, and scaling down to 7

https://devcenter.heroku.com/articles/dyno-types

seems like django 3.2 served with uvicorn under peak load is twice as slow
in a production environment ...
pretty spiky to 4x slower in comparison to using gunicorn and eventlet
with the same number of web workers ( 7 heroku Performance L )

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32773#comment:3>

Django

unread,
May 21, 2021, 2:59:07 PM5/21/21
to django-...@googlegroups.com
#32773: Production Configuration of Django 3.2 with gunicorn and uvicorn
-------------------------------------+-------------------------------------
Reporter: allen-munsch | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by allen-munsch):

support question moved to: https://forum.djangoproject.com/t/django-3-2
-asgi-uvicorn-is-not-production-ready/8003

--
Ticket URL: <https://code.djangoproject.com/ticket/32773#comment:4>

Reply all
Reply to author
Forward
0 new messages