Which http server for K8s? (Gunicorn?)

Up to now I used Gunicorn and virtual private servers to run my applications.

Now I would like to use Kubernetes.

According to this answer you don’t need Gunicorn in a K8s environment.

Which http server do you use instead? Just runserver?

Follow-up question Gunicorn workers in K8s?

That’s a terrible answer. Do not use runserver in production. As per docs:

DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. (And that’s how it’s gonna stay. We’re in the business of making Web frameworks, not Web servers, so improving this server to be able to handle a production environment is outside the scope of Django.)

Use gunicorn.

1 Like

I just started to wondering the same thing: Does gunicorn add a value to django apps in kubernetes clusters anymore? Running as a process manager?

Since in kubernetes era we don’t really need gunicorn for uvicorn as a process manager anymore. As this answer mentioned answer, kubernetes pod schedulers now handle django apps/containers as gunicorn handles uvicorn workers. And via ingress controlled Load Balancer every requests goes to correct django app/container/replica.

Another great example about it can be found on FastAPI doc replication:

If you have a cluster of machines with Kubernetes , Docker Swarm Mode, Nomad, or other similar complex system to manage distributed containers on multiple machines, then you will probably want to handle replication at the cluster level instead of using a process manager (like Gunicorn with workers) in each container.

In those cases, you would probably want to build a Docker image from scratch as explained above, installing your dependencies, and running a single Uvicorn process instead of running something like Gunicorn with Uvicorn workers.

Ofc the scope of my question is async apps —uvicorn with gunicorn, not sync wsgi.

1 Like