FastAPI deployment concepts related to ASGI servers and process managers

06-05-2025

Uvicorn version 0.30.0:

ASGI servers and worker managers:

  • installing FastAPI comes with the recommended production ASGI server (uvicorn) by default

Starting multiple workers:

Passing in config to uvicorn:

How many workers should you run?

Uvicorn vs gunicorn:

# using uvloop and httptools
gunicorn -w 4 -k uvicorn.workers.UvicornWorker
 
# pure python implementation
gunicorn -w 4 -k uvicorn.workers.UvicornH11Worker
 
# uvicorn_worker module (from the uvicorn-worker package)
gunicorn example:app -w 4 -k uvicorn_worker.UvicornWorker

Local development with locally-trusted SSL certificates: