cookiecutter / cookiecutter-django

Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.
https://cookiecutter-django.readthedocs.io
BSD 3-Clause "New" or "Revised" License
12.16k stars 2.91k forks source link

Use Daphne for HTTP/2 with ASGI instead of Gunicorn #2510

Open Andrew-Chen-Wang opened 4 years ago

Andrew-Chen-Wang commented 4 years ago

Description

If you track #2506, I've implemented ASGI + Websocket support. Before, in order to use HTTP/2. you would need to use Django channel's methodology to get faster speeds because then you'd want to be using Daphne, which is officially developed by Django.

Rationale

Faster speeds because sending in binary, and it's based on "Google’s SPDY Protocol (originally designed to speed up the serving of web pages). It was released in 2015 by the Internet Engineering Task Force (IETF)."

Use case(s) / visualization(s)

Less need for configuration. Implements #2506 and would actually lessen the number of dependencies there, too.

wadkar commented 4 years ago

This assumes that uvicorn/asgi is front facing the user in production? I always imagined adding an nginx frontend to handle HTTP/2 (and SSL) termination for production deployment. Is this issue not relevant in that use case?

Andrew-Chen-Wang commented 4 years ago

Unfortunately, Gunicorn + Uvicorn does not support HTTP/2. Daphne replaces the unicorns entirely as a WSGI OR an ASGI. Nginx has nothing to do with this; it’s parallel to Traefik as both are load balancers.

We apparently replaced nginx with Traefik due to security issues with Docker, so... yea. I’d recommend against it.

wadkar commented 4 years ago

Thanks, traefik is an added component increasing operational complexity but that's fine.