We have been trying to use Django with Uvicorn via ASGI interface. As our use case is that our service acts as a wrapper for a 3rd party API service so using ASGI was a better choice because most of the time our service will be waiting on 3rd party service.
Now the problem, I was assuming that if all middlewares are async and the view is async then uvicorn will have one thread to handle multiple requests. But when I simulate the traffic by a script, about 200 requests then uvicorn starts creating new threads. So it seems that django is using one request per thread. BTW To see the number of active thread I'm tracking them via the Activity monitor in Mac. To debug this I've started a new projects with empty list of middlewares and a view of 2 lines which just defines the function in one and sleeps in second. Sleep function is imported from asyncio.
Isn't Uvicorn supposed to use one tread for all the requests.
Regards
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1c57aad5-21c6-40b3-962a-876a05320118n%40googlegroups.com.
No comments:
Post a Comment