How do I maintain state in my web application?

The most effective method of achieving statefulness in your web application is to ensure that state is stored in a medium that is accessible from all the back-ends in your load-balanced cluster. For instance, through information stored in a database or on a network-mounted filesystem. This has the major advantage of allowing true load balancing to take place over your cluster.

In some situations, this approach is not available. There are therefore a number of ways in which you can cause the load balancer to ensure that a given user will always be directed to the same back-end.

  • Map specific URLs to a single back-end, e.g. map .+\.cgi (regular expression match)

  • Setting a cookie in your application called 'X-Zeus-Backend' with the name of the back-end you wish clients to keep returning to. You may wish to delete this cookie once the transaction is completed.

  • Enabling the 'sticky cookies' feature in the load balancer. A session id is stored in a cookie named in the load balancer configuration. This solution doesn't require any changes to the web application.

  • Enabling mapping-based cookies. Similar to the session-based cookies, cookies are automatically generated by the load balancer on the basis of URL to back-end mappings already configured.

For more information, please refer to Chapter 7 of the Zeus Load Balancer user manual.

Content Manager [Administrator] 12 August 2005 Bookmark with del.icio.us Post this article to Digg Post this article to reddit Post this article to Facebook Tweet this article  

Recently...

Other Resources