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.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1OTU5MjEsIm5iZiI6MTczOTU5NTYyMSwicGF0aCI6Ii8xNDE5MDIzMjMvMzY5Mzc0MjQ2LWQzMTUxMTExLTBjOWQtNDViYS04ZTIwLTAzODRlM2FlMmQ1Yi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxNVQwNTAwMjFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hNmYxODZiN2JmNWNhZTUyNDdlZWJiZWViZWZlZmVkMjY0ZWY3NzE5YjY1ODgwNzEyMDA0OTA4Mzg1MjBmNmM1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.uGQw-Lez12MdOT10x3JZ1yz26UOJspyL3YqcQ47IurE)
![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.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1OTU5MjEsIm5iZiI6MTczOTU5NTYyMSwicGF0aCI6Ii8xNDE5MDIzMjMvMzY5Mzc0MzQ1LTVmZTNmNTZlLWFmODgtNGI2Zi04ZmIwLTY2YmNkNTZjNzRhMy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxNVQwNTAwMjFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mNzAyNTY3MmRkZWVkZjQwZTIwODNhMWQyZjQ4NTZlZGEzYzExMmRhNjY5MGQ5ZWNkZmE5ZjQ5YmQ3ZTQ3YTc1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.IxFqnbv_Ks1ZpUhx4oZPTbqFs9aU26qcDgSr_3dW6vs)
Uvicorn version:0.30.6
With default worker=1
with workers=5
Beta Was this translation helpful? Give feedback.
All reactions