Production server for best performance #7101
-
|
Which gives the best performance in production? In uvicorn docs recommends use gunicorn (https://www.uvicorn.org/#running-with-gunicorn): But i think it not actual when using docker. |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments
-
Beta Was this translation helpful? Give feedback.
-
|
We use custom Dockerfile. And balance worker manualy (on uvicorn ). Wondering if the upgrade to Gunicorn is worth it? |
Beta Was this translation helpful? Give feedback.
-
|
it is recommended to use Gunicorn in production ( with Uvicorn workers). you can create a Custom Dockerfile . just check the |
Beta Was this translation helpful? Give feedback.
-
|
It's recommended by But talking about numbers (performance), I didn't find any comparison between those... |
Beta Was this translation helpful? Give feedback.
-
|
For production deployments we recommend using gunicorn with the uvicorn worker class. |
Beta Was this translation helpful? Give feedback.
-
|
I will add something that is a bit different from the above comments, to give you something else to think about. Gunicorn appears to have lots of good stuff and is probably sufficient for a lot of people, but for a project that I have worked on Gunicorn did not appear to be suitable/necessary. After some trial and erroring along with lots of researching, I discovered the reasons for this had to do with our architecture. We are running our application on Kubernetes, which had a few implications on this decision:
If by using Docker, you mean using Docker Swarm, then you may be in a similar situation to what I was in, and really you could do things either way. If you scale with Swarm, you will be consistent in your scaling with Swarm at least, and if you do something like we do by killing/restarting containers, you will achieve that with Uvicorn easily. But this is where you need to decide what is best for you. Disclaimer: I have never run an app in Gunicorn so I have no production experience with it over a significant period of time, only with trying to use it. Maybe the 2nd point is solvable, but the first point still stands, for me anyway. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you, @Kennpow this is useful information. I think we will eventually come to using Kuber. |
Beta Was this translation helpful? Give feedback.
-
|
@Kennpow have you tried Knative? If not definitely check it out. You can do a lot more than Gunicorn able to do. Some pros:
|
Beta Was this translation helpful? Give feedback.
-
|
Haven't tried it @ycd, looks like an interesting project though |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the discussion here everyone. 🍰 There's a lot of new info in the docs about deployments including how and when to combine Uvicorn with Gunicorn (or not): https://fastapi.tiangolo.com/deployment/
|
Beta Was this translation helpful? Give feedback.
-
|
Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs. |
Beta Was this translation helpful? Give feedback.
Thanks for the discussion here everyone. 🍰
There's a lot of new info in the docs about deployments including how and when to combine Uvicorn with Gunicorn (or not): https://fastapi.tiangolo.com/deployment/