Migration from wsgi to asgi questions
See original GitHub issueWe have a django app running on gunicorn with eventlet workers. But we are not satisfied with eventlet cause it monkeypatches everything and works badly with tooling. So we decided to move to asgi.
- I replaced gunicorn eventlet worker with UvicornWorker
- I replaced
threading.local
usage withasgi.Local
- For cachetools we need to use
threading.RLock
becausecachetools
is not threadsafe
And after that, we ran a load test. Seems like with the asgi server we lost about 30% of performance.
So, questions are:
- Are there any guides/docs where I can find how to tune asgi server? Anything about performance?
- Are there any docs that describe how asgi works with django? I’m not sure but looks like there is main asyncio loop and for each request, asgi runs separate thread (and it looks like I must make
async_to_sync
functions that do network requests) - Is it safe/needed to use
threading.RLock
inside sync code or should I replace it with something? - Should I use
asgi.Local(thread_critical=True)
orasgi.Local()
and howthread_critical
works with different code?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Does anyone have experience migrating a large project from ...
I have a WSGI deployment with gunicorn and looking to switch to ASGI. I played around with a small django-channels project but I...
Read more >Unable to run async functions after migrating from WSGI to ...
While implementing channels feature in DRF I migrated from WSGI to ASGI . So currently I have REST API and channels in same...
Read more >How to deploy with ASGI - Django documentation
ASGI servers usually take the path to the application callable as a string; for most Django projects, this will look like myproject.asgi:application ....
Read more >A Guide to ASGI in Django 3.0 and its Performance - Arunrocks
A blog by Arun Ravindran, author and speaker, about Python, Django and other curious things.
Read more >ASGI Documentation
1.1 What's wrong with WSGI? You may ask “why not just upgrade WSGI”? This has been asked many times over the years, and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@carltongibson I will go to the forum with some questions, thanks. But question about performance is suitable here as I think, it’s important.
@allen-munsch No, we returned to eventlet ¯_(ツ)_/¯