Kubernetes deployment of Wt application and horizontal scaling
Added by Francisco Cunha 10 days ago
Hi everyone,
I am in the process of deploying a containerized Wt application using docker and kubernetes. My app uses some legacy c++ codebase which relies on few global variables, and because of this I have the requirement of configuring each instance of my WApplication to be a dedicated-process, thus enforcing a strict isolation between sessions.
I am not a kubernetes expert, and I don't want to center this question too much on kubernetes but, instead, on mechanisms potentially offered by Wt to address the problem I will try to demonstrate below.
Let's imagine user A instantiates my application , and the execution of this instance was assigned to kubernetes pod A . Let's now say user B creates a new instance which is also a dedicated process running "side by side" with user's A instance in the same kubernetes pod . Let's imagine user C joins the same pod being shared by users A and B and at this point, pod 1 becomes saturated in terms of hardware resources e.g. CPU. According to autoscaling policies offered by kubernetes, the next request performed by user A will trigger the launching of a new pod (pod 2) to serve an app instance to user A. At this moment, user A will probably suffer a sudden logout since his sessionId no long refers to the actual wt server serving the instance he is interacting with. In fact, user A is redirected by kubernetes to a new pod that lacks the context of the session he was running on previously on pod 1. This is a classic session persistence and sticky sessions problem.
Session affinity can be set in kubernetes so that requests from a given IP are always redirected to the same pod.
However would be more efficient and scalable to store the session information in some decentralized database, so that the session and its status could be "restored" in another pod without enforcing the reservation of the pod to the IP. Otherwise, the load distribution can easily become too asymmetric.
Does anyone knows/uses any strategy to deal with problems like this in Wt applications?
Sincerely,
Francisco
Replies (1)
RE: Kubernetes deployment of Wt application and horizontal scaling - Added by Christian Meyer 7 days ago
You could set SessionID Prefixes, which is used by HAProxy to route to different backend servers.
There is a wiki page: https://redmine.emweb.be/projects/wt/wiki/Using_HAProxy_as_a_reverse_proxy#Using-session-affinity
I am not sure how kubernetes would do that, but I am sure there is a similar filter option
Good Luck!
Christian