I have a questions regarding Nodejs
in kubernetes
. As I want my service to be scalable by the kubernetes
, means that I will have multiple pods under 1 service.
lets say I have Pod-1 Pod-2 and Pod-3. Then I will run a puppeteer in the pod based on the request.
For example if a request is like bellow
{
"id": "A"
}
If id=A is assigned to Pod-2 for the first time, then Pod-2 will start a puppeteer based on the id=A. While my puppeteer is opened forever (to listen event from a website). Thats why I need id=A to be always processed by Pod-2 forever.
If Pod-2 has a failover, then the service will create a new freshly pod (lets say it as a Pod-4), and kill the Pod-2. since Pod-2 is killed, then the puppeteer is also killed. so any new request for id=A can be routed to anywhere of Pod-1,Pod-3 or Pod-4. Once it is routed to the new Pod, then I will start a new puppeteer based on the id in that Pod
Is this achievable?
P.S. I was looking online, and I found out Akka, that seems can solve this issue. But Akka is meant for Java. When I see Akka for nodejs such as akkajs
or comedy
, i can't picture how it can work in kubernetes.
Edit-1 : Seems like sticky session
does not solve this issue. since sticky session
cookies has a lifetime. once the time is reached, the cookies will be deleted, and a new pod might be selected and routed to. Since I want the request to be sent to that pod as long as the pod lives