Installation guide
Chapter 17. HTTP session state replication
HTT P session state replication is a means of distributing clients' state across multiple servers. T he
following terms are important in understanding load balancing.
Software Load Balance r
A dedicated software-based service designed to distribute HT TP client session requests across
multiple computer servers (cluster). T he primary directive of a software load balancer is to maximize
resource utilization, reduce request response times, and prevent server overload. T he load balancer
forwards client session requests to a server cluster, based on server load and availability.
Client Session
A semi-permanent connection between the client (an application) and the server. T he load balancer
determines whether the client session is created with persistence, or whether a client session is
redistributed based on server load and availability.
Session Persist ence
Session persistence is a feature where information about a client's session is stored by the server so
that if the client's connection is interrupted temporarily, the session can continue at the time the
connection error occurred. A persistent session is also commonly known as a sticky session .
Sticky Session
See Session Persistence.
Section 3.1, “Configure worker nodes in mod_jk” describes how to configure session state persistence
in the load balancer to ensure a client in a session is always routed to the same server node.
Session persistence on its own is not a best-practice solution because if a server fails, all session state
data is lost. For example, if a customer is about to make a purchase on a web site, and the server
hosting the shopping cart instance fails, session state data associated with the cart is lost permanently.
One way of preventing client session data loss is to replicate session data across the servers in the
cluster. If a server node fails or is shut down, the load balancer can fail over the next client request to
any server node and obtain the same session state.
Using a load balancer that supports session persistence, but not configuring web applications for
session replication, allows you to scale your implementation by avoiding the cost of session state
replication: each request for a session will always be handled by the same node.
Session state replication is more expensive than basic session persistence, but the reliability it provides
for session state data makes it important when creating a load balanced cluster.
17.1. Enabling session replication in your application
To enable replication of your web application you must tag the application as distributable in the
web.xml descriptor. Here's an example:
<?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<distributable/>
</web-app>
You can further configure session replication using the replication-config element in the jboss-
web.xml file. However, the replication-config element only needs to be set if one or more of the
default values described below is unacceptable. All of the configuration elements are optional, and can
be omitted if the default value is acceptable.
Here is an example:
JBoss Enterprise Application Platform 5 HTTP Connectors Load Balancing Guide 67