Gunicorn workers in Kubernetes?

I am unsure how many workers I should use, if I use django+gunicorn via Kubernetes.

Should I use 1, since scaling gets done by K8s?

Which worker class do you recommend for K8s?

Up to now I don’t use any async stuff.

BTW, this is a follow-up question to Which http server for K8s?

Stick with the default sync one. The others all come with edge cases that need considering.

If you scale with k8s running many single-process gunicorns, then for each you will pay a little overhead for running multiple leader gunicorn processes, and for the multiple ports they’ll open and need load balancing between. I think it makes sense to run a one gunicorn container per server, at the recommended size of 2n+1 workers where n = num processors.

2 Likes