<p>We have an app that handles request which could take several minutes to return a response. Does it make sense to put this app in a pod and replicate many times in the same node so we can handle each request on a new thread (Considering nodejs is single threaded)?</p>

Daniel Kobe
<p>The use-case here is quite a bit, unsteady. As per your say your application is a single threaded one, and you want to increase the pod as soon as a new request is fired only if the previous pod is busy or has a lock, in simplest terms a new pod to come with a new request if the previous pod is busy.</p>

<p>Kubernetes is an Orchestrator for containers and deploying a monolithic application on kubernetes not just bring down all the tremendous that kubernetes can do but also bring lots of overhead with Deployment and automation issues. </p>

<p>Also, the nice thing when you break away from a monolith (= single thread) into a (micro) service oriented architecture you can have an isolated event loop for each service. Because every Node process would be running isolated inside a container!</p>

<p>I would advise you to consider your architectural design of application, break them into multi threaded and then revisit kubernetes.</p>

<p>However quoting the same <a href="https://www.dataversity.net/use-kubernetes-deploy-monolithic-apps/#" rel="nofollow noreferrer">https://www.dataversity.net/use-kubernetes-deploy-monolithic-apps/#</a> <strong>A Linux shell is a Linux shell is a Linux shell.</strong> You can make it work, and the following can be a way ahead.</p>

<p><strong>Strategic Solution:</strong>  You can declare an <strong>HPA</strong>[Horizontal Pod Autoscaler] for your deployment with a flag of <strong>--max-replicas=xx</strong>, then you need to write a job using <strong>request metrics</strong>, that whenever there is request to the service the Deployment should be scaled automatically and descaled likewise. Also you will have to downscale as soon as the request ends. You should use <strong>v2beta2</strong> apiVersion of HPA, as it allows that type of metrics.</p>

<p>Also what I think is that you will have to use the <strong>v2beta2</strong> apiVersion of HPA because you will have to keep the request count to unary so that the requests doesn't generate <strong>5XX</strong> as kubernetes service will send the request to the same pod if such metric isn't set. </p>
