I got this email today from Don Keller in New Orleans regarding PHP interacting with a load balancer:
I read somewhere that the load balancer you run must support sessions, otherwise you must use cookies.”
This is a common type of question that people who are on the application development side of the fence have regarding load balancers.
With regard to PHP sessions, this typically means that the application is “stateful”, that is, there is information regarding a particular session (such as shopping cart contents, login credentials, etc.) that are stored only on an individual server, and not shared amongst a group of servers.
Most modern applications these days are stateful, whether it’s on PHP, or Websphere, or just about any other platform.
For stateful applications to work with load balancers, the load balancers need to do persistence, which keeps a specific user tied to a single server, even though there may be several or even dozens of other servers available. And the best persistence for web serving is cookie persistence.
It’s very simple to setup, and usually involves a simple check box in the load balancer’s configuration. Cookie persistence (specifically, active-cookie) inserts a cookie into an HTTP header which it then uses to identify which server subsequent requests should go to. It requires not additional configuration on the application, and the inserted cookie will not interfere with any existing cookie.
So the answer is simple: With a PHP application that uses sessions, you’ll need to configure persistence, you’d be wise to select a load balancer that supports cookie persistence.

