Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 904
Afshin Mehrabani Avatar asked Aug 15 '17 11:08

Afshin Mehrabani


2 Answers

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.

like image 75
nckturner Avatar answered Oct 04 '22 16:10

nckturner


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

like image 28
sfgroups Avatar answered Oct 04 '22 16:10

sfgroups