By: Frank De Rienzo
Engineer
Macromedia
Among the many features provided by Macromedia's Web server
clustering solution, ClusterCATS provides a feature called
session-awareness. Session-awareness ensures that when a
session begins on a particular clustered Web server, it
will remain on that server until it is complete.
ClusterCATS load balancing will not threaten to move any
session from a particular server in a session-aware or sticky
cluster to a different server in that cluster. Subsequent
inbound sessions are prone to redirection based on intervention
queued by the intelligent decisions of the clustered server's
load-balancing algorithm. This algorithm works together
with load information provided by the rest of the clustered
servers.
In ColdFusion 5.0, session-awareness has been enhanced
from previous versions by incorporating interaction between
cookies and the HTTP referred_by field; the referred_by
field adjudicates in the absence of cookies.
Two general approaches exist to maintaining a ColdFusion
session state. The first technique is to have a common state
repository using Client Variables and persist all per-client
data. If the storage is shared, any server can serve the
client. This approach provides better reliability and does
not require session-awareness when the Web servers are clustered.
The second technique is to use session variables. When
you place servers running with session variables into a
cluster, session-awareness binds the client to the server
that contains its in-memory state. This approach provides
better performance.
In practice, some combination of client and session variables
may be optimal. This article provides two session-aware
management tips. The article assumes that you are using
session variables in a clustered environment and require
session-awareness. The first example-based procedure will
demonstrate how to customize an error message to help your
customers refill their shopping cart if state is lost due
to a disk crash or hardware failure. The second procedure
describes how to allow third-party sites to set up resilient,
failover-enabled links to content on your session-aware
cluster.
Our working example
When session-awareness is used in conjunction with DNS RoundRobin
distribution, the URL line in the client browser will actually
change from the RoundRobin name to the actual name of the
sticky server as each session is locked down onto a particular
server. Let's illustrate using the following fully qualified
host names and IP addresses properly configured in DNS:
Forward Entries
www1.central-orders.com 192.168.25.1
www2.central-orders.com 192.168.25.2
Reverse Entries
192.168.25.1 www1.central-orders.com
192.168.25.2 www2.central-orders.com
RoundRobin Entries (forward only)
www.central-orders.com 192.168.25.1
www.central-orders.com 192.168.25.2
When a browser hits stickypage.cfm at www.central-orders.com
in a session-aware cluster, the URL line in the browser
will change to either www1.central-orders.com or www2.central-orders.com
matching the server on which the session is locked. If a
session is started on www1.central-orders.com, it will remain
immune to any redirection away from www1.central-orders.com,
triggered by the load-balancing algorithm.
Figure 1: ClusterCATS changes the URL line.
Part I: Editing the error URL message
Continuing to follow our example, if www1.central-orders.com
crashes or disappears then its IP address (192.168.25.1)
would failover to its cluster-mate www2.central-orders.com,
interrupting the sticky session. In this case the browser
will pop up a message as follows:
stickypage.cfm is not currently available in
cluster central_orders
A similar message also appears if all Web servers in a ClusterCATS
cluster are busy or restricted. A browser request to any member
of the cluster will receive an HTTP 503 (server too busy)
failure response from the server. The next section of this
article explains how to customize the error message to tell
customers how to restart their session on a different server
in the cluster.
Following our example, trying to browse stickypage.cfm
on server www1.central-orders.com in the completely busy
cluster central_orders returns the error stickypage.cfm
is not currently available in cluster central_orders. We
do not like this error and would like it to read:
Wow! Bang! Something very bad just happened to
the Web server hosting your session. Please go back to www.central-orders.com
and refill your shopping cart on a new server. We apologize
for the inconvenience.
To override the default 503 error message with this friendlier
message, you must first create a simple HTML (sorry.htm) page
that presents your desired message. After creating sorry.htm,
you must edit the ClusterCATS server entries in the registry
for your platform. Anytime you edit your registry, be sure
to create a fresh backup before starting.
In the following procedure, you will add a value called
"ErrorUrl" to each desired ClusterCATS server registry key.
This value will specify the name of the file, sorry.htm,
relative to the server's document root. The registry editing
procedure is different for Window NT and Solaris/Linux platforms.
For Windows NT:
| 1. |
Edit
the registry and open the key.
HKEY_LOCAL_MACHINE | SYSTEM |
CurrentControlSet | Services | BrightTiger |
Servers
Under the Servers key, you should see the names of the
current cluster members for this system. These are the
individual "server keys" that you modify in the next
step. Following our example, you would find the server
key www1.central-orders.com and www2.central-orders.com
on each server respectively. |
| 2. |
Continuing
with our example, for each of these cluster members
that you wish to customize for the 503 error response,
create the following REG_SZ value under its server key:
sorry.htm where sorry.htm is the file containing your
selected error text, relative to this server's Web document
root. For example, the sample file above might be physically
located in C:/Inetpub/wwwroot/sorry.htm. |
| 3. |
Close
the registry editor. |
| 4. |
Test
the change by restricting all servers in the cluster.
A one-node cluster simplifies this test and browsing
the server with a Web browser. Your customized error
displays. |
For UNIX:
NOTE: Solaris/Linux versions of ClusterCATS uses a file
called bt.registry that is similar to the Windows NT registry.
The following procedure requires that you manually edit
the file. Be careful because this ordinary text file requires
precise formatting requirements.
| 1. |
Log
onto the UNIX computer as super user (root). |
| 2. |
Stop
all ClusterCATS activity with the command:
# /usr/lib/btcats/btadmin stop all
|
| 3. |
Edit
the file /usr/lib/btcats/database/bt.registry with an
editor. |
| 4. |
Search
for the string:
hkey_local_machine\system\currentcontrolset\services\brighttiger\servers:6
Under this key, you should see the names of the current
cluster members for this system in distinct blocks for
text. Continuing our example, this entry is the first
part of a server called www1.central-orders.com:
hkey_local_machine\system\currentcontrolset\
services\brighttiger\servers\www1.central-
orders.com:214 ClusterMate: ; REG_SZ
ClusterName: central_order; REG_SZ
InstanceName: https-www1; REG_SZ
|
| 5. |
For
each server that you wish to customize for the 503 error
response, create the following value: ErrorUrl: sorry.html;
REG_SZ.
Sorry.htm is the file containing your special error
text, relative to this server's Web document root.
For example, the sample file above might be physically
located in: /usr/netscape/suitespot/https-www1/docroot/sorry.htm.
Your modified server key should look similar to:
hkey_local_machine\system\currentcontrolset\
services\brighttiger\servers\ www1.central-
orders.com:214 ErrorUrl: sorry.html; REG_SZ
ClusterMate: ; REG_SZ ClusterName:
central_order; REG_SZ InstanceName: https-
www1; REG_SZ
|
| 6. |
Save
the file and exit the editor. |
| 7. |
Restart
the ClusterCATS service with the following command:
# /usr/lib/btcats/btadmin start all
|
| 8. |
To
test the change, restrict all servers in the cluster.
A one-node cluster simplifies this test. Browse the
server with a Web browser. Your customized error displays.
|
Part II. Enabling third-party sites to set up resilient
links to a session-aware cluster
To illustrate this scenario, we will add some third-party
servers to our example as shown in the following diagram:
Figure 2: Third-party server opens a session.
As soon as any browsing customer hits a link on a third-party
server that points to your session-aware site, that third-party
server has opened a session. All subsequent hits through
that same third-party link will be redirected to the same
server in your cluster. If that server fails, the link on
the third-party server will receive the customized error
URL from the previous step. To provide uninterrupted service
in the event of a server failure running CF 4.5X in this
sticky session-state scenario, you must provide a nonsticky
redirection page to connect the third-party link to your
session-aware cluster. The best way to set this up is to
add to our example. Go to your DNS server and add two more
entries to facilitate adding a non-session-aware cluster
to your Web server:
Forward Entries
www1.central-orders.com 192.168.25.1
www2.central-orders.com 192.168.25.2
redirect1.central-orders.com 192.168.25.3
redirect2.central-orders.com 192.168.25.4
Reverse Entries
192.168.25.1 www1.central-orders.com
192.168.25.2 www2.central-orders.com
192.168.25.3 redirect1.central-orders.com
192.168.25.4 redirect2.central-orders.com
RoundRobin Entries (forward only)
www.central-orders.com 192.168.25.1
www.central-orders.com 192.168.25.2
wwwlink.central-orders.com 192.168.25.3
wwwlink.central-orders.com 192.168.25.4
| 1. |
On
the Web server hosting www1.central-orders.com, add
the IP address for redirect1.central-orders.com, 192.168.25.3.
On the Web server hosting www2.central-orders.com, add
the IP address for redirect2.central-orders.com, 192.168.25.4.
Set up new virtual servers called redirect1.central-orders.com
and redirect2.central-orders.com on each Web server
platform. Make sure to bind the new virtual servers
to their corresponding IP addresses. |
| 2. |
Place
the new virtual server into a non-session-aware cluster.
Launch ClusterCATS Explorer. Right-click on the cluster.
Choose configure-administration-uncheck the session-aware
block. |
| 3. |
Place
a redirection page at the document root of each of your
new servers and offer the RoundRobin name, wwwlink.central-orders.com,
as the link used by third-party sites. The RoundRobin
name, wwwlink.central-orders.com, distributes sessions
between the two non-session-aware virtual servers that
host your redirection pages. Following our example,
on redirect1.central-orders.com, place a page that redirects
you to www1.central-orders.com. On redirect2.central-orders.com,
place a page that automatically redirects you to www2.central-orders.com.
More specifically, following our illustration exactly,
place <cflocation url="http://www1.central-orders.com/sticky.cfm"
addtoken="No"> in a default.cfm file at the document
root of the virtual server redirect1.central-orders.com
and place <cflocation url="http://www2.central-orders.com/sticky.cfm"
addtoken="No"> in a default.cfm file at the document
root of the virtual server redirect2.central-orders.com.
|
The following diagram illustrates this technique:
Figure 3: How to place a redirection page at the document
root.
This technique works with ColdFusion 4.5.X, but it does
not work with ColdFusion 5.0. In ColdFusion 5.0, ClusterCATS
uses an enhanced means of maintaining session-awareness.
For ColdFusion 5.0, the recommended solution is to either
provide a link on a customized error URL page as illustrated
in the first part of the article, or operate using the server-monitoring
agent rather than clustering.
The following article provides information about the server-monitoring
agent:
http://www.allaire.com/Handlers/index.cfm?ID=21570
Employing load-balancing hardware is also a viable solution.
See the following article for guidance about choosing among
the various hardware-based, load-balancing solutions:
http://www.allaire.com/handlers/index.cfm?ID=21780