python-discord / api

A FastAPI-based service that allows our services to communicatie with our database.
MIT License
10 stars 1 forks source link

Switch to uvicorn in production #24

Open ChrisLovering opened 2 years ago

ChrisLovering commented 2 years ago

Since we use kubernetes in production, we should handle replication at the cluster level instead of using a process manager (like Gunicorn with workers) in each container.

See: https://fastapi.tiangolo.com/deployment/docker/#when-to-use

jchristgit commented 2 years ago

I'm 50/50 on this. A completely separately container here will be a lot heavier to scale up and down than simply using multiple workers in a single container.

ChrisLovering commented 2 years ago

Yea I think it's a trade off between better multi-core support and better load balancing.

Do you know off the top of your head what the load difference would be? The reason I ask it afaik gunicorn has a management process on top of each of the worker processes, which wouldn't be needed with individual containers. So we do drop one of the resource sinks by doing this.

ChrisLovering commented 2 years ago

cc @python-discord/devops