Fastapi recommends use gunicorn with uvicorn workers why?
See original GitHub issueFirst Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn’t find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google “How to X in FastAPI” and didn’t find any information.
- I already read and followed all the tutorial in the docs and didn’t find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- I commit to help with one of those options 👆
Example Code
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
Description
Currently i use uvicorn only in production but when i check the docs it says you should run uvicorn workers inside gunicorn, what do i get when i replace it with gunicorn?
Operating System
Linux
Operating System Details
No response
FastAPI Version
latest
Python Version
3.9
Additional Context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Server Workers - Gunicorn with Uvicorn - FastAPI
You can use Gunicorn (or also Uvicorn) as a process manager with Uvicorn workers to take advantage of multi-core CPUs, to run multiple...
Read more >FastAPI Gunicorn Uvicorn for Production Deployment with ...
It is not a bad idea to use tiangolo/uvicorn-gunicorn but I recommend you to lock the version of the container, this is in...
Read more >Deployment - Uvicorn
Gunicorn is probably the simplest way to run and manage Uvicorn in a production setting. Uvicorn includes a gunicorn worker class that means...
Read more >tiangolo/uvicorn-gunicorn - Docker Image
You can use Gunicorn to start and manage multiple Uvicorn worker processes. That way, you get the best of concurrency and parallelism in...
Read more >The Ultimate FastAPI Tutorial Part 6b - Basic Deployment on ...
Then Gunicorn would start one or more worker processes using that class. And Uvicorn has a Gunicorn-compatible worker class. Using that ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it’s important to look at the bigger picture in a production setup. If you’re running containerized, replicated deployments on k8s, you don’t really need a process manager for resiliency or upgrades. What you do need however is good load balancing, and Gunicorn / Uvicorn workers (well, really the OS itself) provide that. k8s load balancing is just iptables by default I believe, so not even round robin.
You can read exactly what you search in uvicorn documentation: https://www.uvicorn.org/deployment/#using-a-process-manager