Is this necessary to have multiple processes / threads in a Kubernetes pod?

8/15/2017

I'm using uwsgi in a container hosted in a Kubernetes cluster. UWSGI supports a traditional master / slave architecture to provide a better availability for the application but my question is, should I even use this feature?

In other words, when I need more processes to handle and compute requests, should I increase the number of pods in the cluster or should I still use master / slave mode of UWSGI to respond to the requests?

-- Afshin Mehrabani
django
kubernetes
uwsgi

3 Answers

8/16/2017

Be conscious of having enough threads/processes/pods to maintain availability if your application blocks while serving each HTTP request (e.g. Django). There is going to be some pod startup time if you're using a horizontal pod autoscaler, and I found with a high traffic application I had much better availability with uwsgi and the application within each pod (same container), and a separate nginx pod doing reverse proxying and request pooling when all the uwsgi workers were busy.

YMMV but at the end of the day, availability is more important than sticking to the single process per pod rule of thumb. Just understand the downsides, such as less isolation between the processes within the same container. Logs are available on a per container basis, so there won't be isolation between anything in the same container using the built in kubectl logs functionality.

-- nckturner
Source: StackOverflow

8/15/2017

Recommended way to manage this in Kubernetes is to increase the number of PODs based on the workload requirements.

-- sfgroups
Source: StackOverflow

8/23/2017

We use a deployment model in which a django based app is served by gunicorn with couple of worker processes. We have further tried to scale this pod to 2-3 replicas and have seen performance improvements.

It's totally upto what works for your app.

Advantage of scaling pods is that you can configure it dynamically, hence not wasting resources.

-- Shahidh
Source: StackOverflow