2023-05-19 –, Saphire C - Web Dev
In the usual scenario, Django is served using WSGI server (gunicorn, uWSGI are the most popular) that work in pre-fork synchronous model,
hence you will need multiple workers and have a “copy” of your application for each worker.
This consumes a lot of memory and drags scalability issues along with it,
since one worker is busy responding to only one request at a time.
Green threads are one solution to NOT rewrite your whole codebase in order to go async without bumping into threads and the notorious GIL.
For the demo a simple Django concurrent application will be used and some benchmarks from a load test.
Django usually is considered slow and bad at doing concurrency because of its synchronous by default nature, but what if you could make it “async” without rewriting all of your codebase? Ever heard of green threads?
Advanced