Nothing particularly now, however if you are working on an older stack that hasn’t migrated to ASGI it’s just not particularly easy.
For long running responses like websockets and SSE you really need to use none threaded worker processes (one websocket connection would clog up a a single worker thread). Until recently the best way to do this was with Gevent with Gunicorn. The asyncio stuff that is coming to Django is a great addition, they have just merged async querysets. However it’s not the full framework yet and so although views and querysets are async, the db adapters are not yet and use a thread pool internally. I’m hoping they get to that level of the framework soon, it’s been a sessions undertaking to asyncify the Django api.
I like the idea of continuing to use the original sync api everywhere except on websocket/SSE views or views with a lot of io (many db query’s and http api calls) where it has a proper advantage.
I haven’t looked in detail recently but I would still consider whether going Gevent/Gunicorn (which is basically magic) is better than asyncio at the moment for Django. May be worth doing some benchmarking.
I kind of wish Gevent had won the battle with Asyncio.
Thanks for the in-depth response. That's really great news about async querysets getting merged! Even with adapter thread pooling, that should dramatically increase Django's throughput and hopefully make it competitive with newer frameworks like FastAPI. I've been impressed that Django has managed to transition to async views basically without any major problems (that I've heard about). Now that they're going async with the ORM, that feels even more risky and something that should probably go slowly. With all the improvements in Django combined with new-ish JavaScript libraries like HTMX/Unpoly, it really feels like new life is being injected into the framework.
For long running responses like websockets and SSE you really need to use none threaded worker processes (one websocket connection would clog up a a single worker thread). Until recently the best way to do this was with Gevent with Gunicorn. The asyncio stuff that is coming to Django is a great addition, they have just merged async querysets. However it’s not the full framework yet and so although views and querysets are async, the db adapters are not yet and use a thread pool internally. I’m hoping they get to that level of the framework soon, it’s been a sessions undertaking to asyncify the Django api.
I like the idea of continuing to use the original sync api everywhere except on websocket/SSE views or views with a lot of io (many db query’s and http api calls) where it has a proper advantage.
I haven’t looked in detail recently but I would still consider whether going Gevent/Gunicorn (which is basically magic) is better than asyncio at the moment for Django. May be worth doing some benchmarking.
I kind of wish Gevent had won the battle with Asyncio.