Hey, guys!
It can be a noob question, but it's really interesting for me.
Why I should use gunicorn with the uvicorn workers instead of using pure uvicorn?
Which features we don't have in uvicorn, but is too good for production?
So: Gunicorn will give you multiple worker processes, as well as monitoring and restarting any crashed processes. We might start to have some of those things built directly into Uvicorn at some point, but for now if you want multiple processes you need to use Gunicorn or some other process manager such as circus.
@tomchristie but if I use docker swarm or kubernets as the main way to scaling my app and the single process will ok for me, I can use uvicorn instead of gunicorn, correct?
tnx for your answer!
Possibly yes. I鈥檝e not used either, so I couldn鈥檛 say for sure if you鈥檇 be getting more efficient resource usage by having multi-process-per-container.
@tomchristie I think that you should recommend running pure uvicorn in production when using container orchestrators such as Kubernetes and set the number of containers (processes) there instead. Kubernetes (and probably its competitors) has options to automatically scale containers up and down depending on CPU and memory usage, thus minimizing the resource usage.
@jmagnusson - Yes I think we'll end up going that way.
It'll be nice if the documentation is updated to use Uvicorn in Swarm/Kubernetes environments. Thanks!
@jmagnusson This also works better with Prometheus instrumentation since you don't have to rely on the not-perfect multiprocessing functionality of the Prometheus client. Just to add to your comment in case someone comes across this
Most helpful comment
So: Gunicorn will give you multiple worker processes, as well as monitoring and restarting any crashed processes. We might start to have some of those things built directly into Uvicorn at some point, but for now if you want multiple processes you need to use Gunicorn or some other process manager such as circus.