Issue: Increased CPU and Memory Overhead with Uvicorn Multi-Processing #2463
Unanswered
jahnavisana2812
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We were previously using Gunicorn with Uvicorn workers for our application. Recently, we decided to shift to using Uvicorn directly, due to improvements in Uvicorn.
However, while Gunicorn used to spawn 5 sub-processes for handling requests, Uvicorn now creates 5 multiprocessing spawn processes using Python's multiprocessing library. This results in noticeable CPU and memory overhead, which we didn't experience with Gunicorn workers.
When running Uvicorn with a single worker, the overhead is not present, but increasing the worker count leads to the issue. I have attached screenshots of our monitoring data, which clearly show the difference in resource usage between configurations.
Is this behavior expected with Uvicorn, or is there a possible fix for reducing the overhead in future updates? Any guidance or suggestions would be appreciated.
Python version:3.11.9
![Screenshot 2024-09-20 at 4 20 18 PM](https://private-user-images.githubusercontent.com/141902323/369374246-d3151111-0c9d-45ba-8e20-0384e3ae2d5b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NDE0MDgsIm5iZiI6MTczODk0MTEwOCwicGF0aCI6Ii8xNDE5MDIzMjMvMzY5Mzc0MjQ2LWQzMTUxMTExLTBjOWQtNDViYS04ZTIwLTAzODRlM2FlMmQ1Yi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwN1QxNTExNDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04MzM4YmFiY2NjZGZiY2Y2NzNiYThhOTljYzg5OWY5OGIxOGQ4YmVmZDA1MGQxNDkxMjIwODQyZDY2YmY1MzNlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.GZTdav-CAQujUlizcRrNLMOnVab-j_FjQGdr8Gs5Nuc)
![Screenshot 2024-09-20 at 4 20 39 PM](https://private-user-images.githubusercontent.com/141902323/369374345-5fe3f56e-af88-4b6f-8fb0-66bcd56c74a3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NDE0MDgsIm5iZiI6MTczODk0MTEwOCwicGF0aCI6Ii8xNDE5MDIzMjMvMzY5Mzc0MzQ1LTVmZTNmNTZlLWFmODgtNGI2Zi04ZmIwLTY2YmNkNTZjNzRhMy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwN1QxNTExNDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zZTAyNjY2ZTYyOGY0NDFmZjMwOWMyMjNkZDlmNjNlYjhmNTllYTljYjJlYTc0MmYyZGE1ZTA3YTZiYzEzMDlhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.hQBwuxIm1rAo4wFdm6D-m5TZPcc4vTsJbqAN_5a_I9I)
Uvicorn version:0.30.6
With default worker=1
with workers=5
Beta Was this translation helpful? Give feedback.
All reactions