|
HTTP state replication This article explains what HTTP state replication is and how to set it up
Introduction
Cluster enabling a Web-module Cluster enabling all Web-modules Debugging Troubleshooting 1 Introduction
This article will explain HTTP state replication for the Orion Application Server, as well as give step-by-step instructions for setting up, running and testing HTTP clustering. Throughout this article, a cluster will mean a number of cluster enabled Web-modules. Each cluster enabled Web-module will be refered to as a cluster node. When a cluster node is started, it is given a specific HTTP-cluster service. The cluster services uses multicast packets to send and receive state changes in a cluster. These packets are sent over the network where they are picked up by other cluster nodes using the same multicast address and port.This also means that the data is available to any application, such as a custom cluster monitor, that has registered itself as a listener on the same multicast address and port. Multicast addresses have IP addresses in the range 224.0.0.0 to 239.255.255.255. Normally, a Multicast packet has a TTL (time to live) value less than 60, which limits the packet to the local network and thereby making sure that they wont flood the network. For more information on multicast and related issues such as TTL, please use a resource such as this as multicast in itself is out of scope for this article. A cluster island is a state sharing subgroup of a cluster. Every cluster node belongs to a cluster island, but the deployer can configure what cluster island a cluster node belongs to. State can only be shared amongst the cluster nodes of a cluster island.
Normally 2 or more cluster nodes uses the same multicast address and port to share state but in some situations it might be better to use different multicast addresses or ports for each cluster island to enable "smart" routing of multicast packets in the network and just send traffic on certain addresses/ports to certain cluster nodes. In order to identify a cluster node the cluster services uses the Applications deployment name (the name attribute specified in the application tag in server.xml) to identify Applications. To identify Web-modules, the URI of the Web-module as it is stated in the Applications application.xml file is used. If the Web-module is packaged into a WAR, it's the URI of the WAR file without the .war suffix. Together, these two identifiers are used to decide if a certain cluster node should be given information about a state change. The cluster sevices allows for any remote RMI-objects or Serializable objects to be replicated over a cluster. Other objects will not be replicated and error messages will be put into the Application log file. Objects must be rebound (through As the Servlet specification mandates that the Servlet Context is local to the JVM where it was created and thus not suited for distribution, the Applications Context should be used instead. Replication of Serializable values bound to the ServletContext is therefore disabled by default. Instructions for enabling ServletContext replication can be found here. 1.1 Normal behaviour The normal behaviour of a clustered Web-module is as follows: 1.2 Requirements In order for HTTP-clustering to work, the following requirements must be met: 2 Cluster enabling a Web-module Any Web-module that is distributable (contains a <distributable/> tag in its web.xml descriptor) can be cluster enabled by following these steps:
Step 1: Deploy the Web-module
Step 2: Bind the Web-module Step 3: Verify deployment and binding Step 4: Configure Web-module to replicate its state Step 5: Configure cluster islands Step 6: Verify cluster configuration Step 7: Configure a LoadBalancer 2.1 Step 1: Deploy the Web-module Deploy the Web-module on all Servers you want to use in your cluster. If the Web-module is part of an Application, you can follow this step-by-step guide for Application deployments. If the Web-module is a stand-alone module, you can follow this step-by-step guide for stand-alone Web-module deployments. Make sure to deploy your Applications using the same deployment name on all Servers. If so preferred, the Application (or stand-alone Web-module) can be placed on a shared drive that all Servers access 2.2 Step 2: Bind the Web-module Bind the deployed Web-module to the Web-site that is to be used. Make sure to bind it to the same root on all Servers so that the Clients URL will be the same. Instructions for binding a Web-module to a Web-site can be found here. 2.3 Step 3: Verify deployment and binding Verify that all deployment and bindings was without issues by accessing the Web-module with a client. 2.4 Step 4: Configure Web-module to replicate its state Edit the orion-web.xml file of all involved Web-modules and add the following to the main body of the <orion-web-app> tag:
Specify [host] if the default multicast host (230.0.0.1) should not be used. Specify [port] if the default multicast port should not be used. The default multicast port is 9127 plus the cluster island number, so for cluster island 1 the port would be 9128 and for cluster island 2 the port would be 9129. Specify [number] if the default id (random seed based on local machine IP) should not be used. The number given needs to be unique for the specific cluster node within the cluster (so multiple cluster-enabled Web-modules can use the same cluster id as long as they all reside on the same Server). If only the default values are needed, leave the tag empty as in listing 2 below.
The multicast host and port is the multicast address that this Web-module's clustering service will use to transmit and receive state information on. It should therefore be the same for all Web-modules that should share state (part of the same cluster island). Sometimes different multicast addresses/ports are used for different cluster islands to enable "smart" routing of multicast packets in the network and just traffic on certain IPs to certain cluster nodes. If the ServletContext should also be replicated (adviced against in the Serlvet specification and therefore disabled by default), the replicate-servlet-context attribute of the <orion-web-app> tag must be given a value of "true", as exemplified in listing 3 below.
Where the value of the replicate-servlet-context attribute should be set to "true" in order for the ServletContext to be replicated ("false" by default). Please notice that only Serializable values bound to the ServletContext will be replicated. 2.5 Step 5: Configure cluster islands If the cluster is going to use more than one cluster island, or if another cluster island than "0" (the default) is to be used, a value needs to be given for the cluster island attribute. Edit the web-site.xml file for the website the Web-module is bound to (for example default-web-site.xml if clustering the default Web-module) and add the following to the <web-site> tag:
Substitute [number] with a number equal or greater than 1 if the default value (-1) is not to be used. If the cluster is to have more than one island, specify different island values for the Web-sites that belong in different islands. Remember that the default clustering port will be 9127 plus the value of the cluster-island attribute. In order for the LoadBalancer to be notified of the existance of the Web-site, a cluster-island value greater than 0 has to be used. Please see the Load Distribution article for more information. Notice that the cluster enabled Web-modules must be bound to web-sites with the same cluster island number in order for state changes to be received. 2.6 Step 6: Verify cluster configuration Verify the HTTP-cluster configuration by starting up the Servers in cluster-debug mode as described here and then access a state altering resource of one of the clustered Web-mdoules. Console output on the Servers of the cluster should show that state is being replicated. Double-check by inspecting the session values of the Web-modules through the administration console view for Sessions. If no easily usable state altering resource exists in the Web-modules, either the SessionExample servlet or a simple JSP page can be used. A sample JSP page is given in listing 5 below.
2.7 Step 7: Configure a LoadBalancer If a load balancer is to be used in front of the Web-site to which the Web-module is bound, the Web-site needs to know about it so that all affected values can me modified. This is configured in the web-site.xml of the web-site the Web-module is bound to. In the main body of the <website> tag, add:
Where balancer-host should be replaced with the hostname of the server which will be running the load distributor and balancer-port with the port that will be used for the same. This host and port will make up the public hostname for the site, so port 80 is a good suggestion. In order for the LoadBalancer to be notified of the existance of the Web-site, a cluster-island value greater than 0 has to be used. Please see the Load Distribution article for more information. If the above steps have been completed successfully the Web-modules should now be able to share their state within the configured island(s). In order for the cluster to be transparent to the client, continue with setting up a LoadBalancer as described here. 3 Cluster enabling all Web-modules By cluster enabling the global Web-module, all Web-mdoule's that are distributable /contains a <distributable/> tag in its web.xml descriptor) can be cluster enabled. To cluster-enable all distributable Web-modules available on a certain Server, follow these steps:
Step 1: Identify the global Web-module configuration file
Step 2: Configure global Web-module to replicate its state Step 3: Configure cluster islands Step 4: Verify cluster configuration Step 5: Configure a LoadBalancer 3.1 Step 1: Identify the global Web-module configuration file The global Web-module configuration file for a Server is pointed out in the server.xml file of the Server. This file is normally located at config/server.xml in the Orion installation directory. Open the file and look for the <global-web-app-config> tag. By default this tag looks like in listing 7 below:
3.2 Step 2: Configure global Web-module to replicate its state Follow the instructions given earlier for Web-module cluster configuration but use the file identified in step 1 above instead of a particular Web-module's orion-web.xml. Notice that all distributable Web-modules on the Server will inherit the specified values. 3.3 Step 3: Configure cluster islands If needed, follow the instructions given earlier to configure cluster islands. 3.4 Step 4: Verify cluster configuration If needed, follow the instructions given earlier to verify the configuration. 3.5 Step 5: Configure a LoadBalancer If needed, follow the instructions given earlier to configure LoadBalancers. If the above steps have been completed successfully all the distributable Web-modules available on the Server should now be able to share their state within the configured cluster island(s). In order for the cluster to be transparent to the client, continue with setting up a LoadBalancer as describedhere. 4 Debugging This section describes common techniques that can be used to debug HTTP-clustering. 4.1 Tracing In order to get trace information from the cluster services, start the Orion Server with the cluster.debug and http.cluster.debug system properties set to true, as exemplified in listing 8 below.
The cluster.debug property will list common debug information to the cosole. The http.cluster.debug property will list HTTP cluster debug information to the console. 4.2 Application logs Issues the Web-module's clustering service has with either sending or receiving state can be found in the Web-modules Applications application.log file per default. If the Web-module was deployed as a stand-alone Web-module, this information can be found in the application.log file of the default application. 5 Troubleshooting This section describes common problems and possible solutions. 5.1 Wrong IP address used for web-site It is not reliable to get the IP address of the local host on all platforms. It is therefore recommended that the value for the host attribute is set correctly. This issue is normally encountered when the LoadBalancer is having troubles identifying the web-site. 5.2 Firewall issues Make sure that any firewalls allows for the Servers to communicate on the configured multicast address in both directions, both sending and receiving information. Using a simple multicast sender/receiver test application allows for testing the configured multicast address and make sure that packets can be both sent and received. 5.3 Proxies/Gateways issues As multicast packets are known to hog down networks if allowed to roam free, most proxies and gateways won't let multicast packets pass. Make sure that the multicast packets can reach all nodes in the cluster and configure any proxies/gateways accordingly. 5.4 Non distributable state If certain objects are not replicated within the cluster, make sure that these values are either Serializable or remote RMI-objects (this also goes for any objects this object is using/referring to). Copyright © 2005 IronFlare AB |