Load Balancing Question
kaikyro said 1 year, 1 month ago:
If I setup two web servers behind a load balancer (say round robin method). Will the load balancer always send clients to the same server consistently or will I need to then add some custom form of session management to my website?
vincent said 1 year, 1 month ago:
There are 3 balancing algorithms to choose from.. “Round-Robin” and “Least Connections” are essentially random; “Source IP” will generally send requests from a particular client to the same server each time.
I would not rely on this as a mechanism to maintain user sessions though. You lose the ability to add and remove machines from the balancer on-demand, and client IPs can also change unexpectedly.
A better solution is storing session state on something shared.. a database, key/value store, shared filesystem, etc. This way any machine can handle any request that comes in without “sticky” sessions.
kaikyro said 1 year, 1 month ago:
Thanks for that, certainly answers the question.
3 min expected wait time