|
Load Distribution This article describes Load Distribution and how to set it up.
Introduction
Starting the LoadBalancer Starting the LoadBalancer using a configuration file Specifying name/ip to listen to Specifying port to listen to Ignoring SessionID Ignoring Clients IP Disallowing keep-alives Setting the minimum cluster island number Setting the maximum cluster island number Setting the server-selection behaviour Configuring cluster islands Configuring cluster island nodes Balancing HTTPS sites Debugging Troubleshooting 1 Introduction
Load distribution or load balancing (these terms will be used interchangeably in this document) mean that some process (front-end) acts as a distributor of HTTP/HTTPS requests and send different requests off to different servers, or back-ends. Throughout this article, a cluster will mean a number of cluster enabled Web-sites. Each cluster enabled Web-site will be refered to as a cluster node.
Bundled with the Orion Application Server is the LoadBalancer which can be used to distribute HTTP/HTTPS requests to different cluster nodes. The LoadBalancer uses the multicast address 230.0.0.2:27512 to receive notification from cluster nodes in order to dynamically add and remove available nodes.
If a cluster node known by the LoadBalancer is gracefully stopped, it will notify the LoadBalancer that it is no longer available. If request is sent to a cluster node that isn't responding, the LoadBalancer will route the request to another cluster node in its list. 1.1 Normal behaviour The default behaviour of the LoadBalancer is as follows: 1.2 Requirements In order for LoadBalancer to work, the following requirements must be met: 2 Starting the LoadBalancer This section describes how to start the LoadBalancer. The LoadBalancer is started using the following command in the Orion installation directory:
The LoadBalancer specific [system properties] are -Dhttp.cluster.debug and -Dcluster.debug. The available options are: -config [path] - used to specify the path to a Loadbalancer configuration file. Details are available here . -host [name/ip] - name/ip address to listen to for HTTP connections on (ALL by default). Details are available here . -port [number] - port to listen to for HTTP connections (80 by default). Details are available here . -dontUseSessionID - tells the balancer not to scan for Servlet session IDs as a means of identifying clients. Details are available here . -dontUseIP - tells the balancer not to route connections based on IP if no session exists/is scanned for. Details are available here . -dontUseKeepAlives - tells the balancer not to maintain keep-alives. Details are available here . -minimumIsland [number] - the minimum island to add to alive servers list. Details are available here . -maximumIsland [number] - the maximum island to add to alive servers list. Details are available here . -selectiontype [random|first]- how to select servers, the default is random, options are: 'random', 'first'. Details are available here . -debug - log information to the console regarding the progress of the load balancer. Details are available here . Each of these options is described in separate sections. When the LoadBalancer is started, the following message should be displayed in the console:
3 Starting the LoadBalancer using a configuration file By default, the LoadBalancer tries to load a configuration file named config/load-balancer.xml. If such a file exists, the LoadBalancer tries to use it. It is also possible to specify a specific configuration file by starting the LoadBalancer with a command similar to the one stated in listing 3 below.
Where [path] should be replaced with the path to a loadbalancer configuration file. The LoadBalancer will output a notification to the console whenever a cluster node register itself with it. 4 Specifying name/ip to listen to By default, the LoadBalancer listens to all available name/ip addresses for incoming HTTP/HTTPS requests. To configure this value either start LoadBalancer with a command like in listing 4 below or by specifying this value for the host attribute in the <load-balancer> tag of the used configuration file as described in listing 5 below.
5 Specifying port to listen to By default, the LoadBalancer listens to port 80 for incoming HTTP/HTTPS requests. To configure this value either start LoadBalancer with a command like in listing 6 below or by specifying this value for the port attribute in the <load-balancer> tag of the used configuration file as described in listing 7 below.
6 Ignoring SessionID By default, the LoadBalancer scans for the Servlet Session ID to identify clients. Clients are identified in order for the LoadBalancer to select the correct backend Server for handling the clients request. To configure the LoadBalancer to ignore the Servlet Session ID either start LoadBalancer with a command like the example in listing 8 below or set the value of the attribute use-session-id to false in the <load-balancer> tag of the used configuration file as described in listing 9 below.
If the LoadBalancer cannot identify clients by the usage of their Servlet Session IDs, the LoadBalancer scans for the clients IP to identify clients. 7 Ignoring Clients IP By default, if the LoadBalancer is configured to ignore Servlet Session IDs, the LoadBalancer scans for the clients IP to identify clients. Clients are identified in order for the LoadBalancer to select the correct backend Server for handling the clients request. To configure the LoadBalancer to ignore the clients IP either start LoadBalancer with a command like the example in listing 10 below or set the value of the attribute use-ip to false in the <load-balancer> tag in the used configuration file as described in listing 11 below.
8 Disallowing keep-alives By default, the LoadBalancer allows for clients to reuse http connections per the HTTP 1.1 specification. To configure the LoadBalancer to disallow keep-alives either start LoadBalancer with a command like the example in listing 12 below or set the value of the attribute use-keep-alives to false in the <load-balancer> tag in the used configuration file as described in listing 13 below.
9 Setting the minimum cluster island number By default, the LoadBalancer will manage all nodes on all cluster islands. It is sometimes needed to be able to specify that a certain loadbalancer should only handle some cluster islands. This is done by specifying the minimum and/or maximum cluster island numbers that the LoadBalancer should listen to. To configure the minimum cluster island number the LoadBalancer should listen to, either start LoadBalancer with a command like the example in listing 14 below or set the value of the attribute minimum-island to the appropriate value in the <load-balancer> tag in the used configuration file as described in listing 15 below.
10 Setting the maximum cluster island number By default, the LoadBalancer will manage all nodes on all cluster islands. It is sometimes needed to be able to specify that a certain loadbalancer should only handle some cluster islands. This is done by specifying the minimum and/or maximum cluster island numbers that the LoadBalancer should listen to. To configure the maximum cluster island number the LoadBalancer should listen to, either start LoadBalancer with a command like the example in listing 16 below or set the value of the attribute maximum-island to the appropriate value in the <load-balancer> tag in the used configuration file as described in listing 17 below.
11 Setting the server-selection behaviour By default, the LoadBalaner will select a cluster node at random when the client first accesses a cluster island. Optionally the LoadBalancer can be configured to select the first registered for a certain cluster island instead. To configure the server-selection behaviour the LoadBalancer should use, either start LoadBalancer with a command like the example in listing 18 below or set the value of the attribute selection-type to the appropriate value in the <load-balancer> tag in the used configuration file as described in listing 17 below.
12 Configuring cluster islands It is possible to add initial islands that should be added to the list of avaialble islands during LoadBalancer initialization. Such entries can be added to the body of the <load-balancer> tag in the used configuration file as described in listing 18 below.
Each island node normally contains a number of <backend-server> nodes (see below that describes initial cluster nodes that should be part of this island. 13 Configuring cluster island nodes It is possible to add initial cluster nodes to the initial islands that should be added to the list of available cluster nodes during LoadBalancer initialization. Such entries can be added to the body of the <island> tags in the used configuration file as described in listing 19 below.
This feature should be avoided as it leaves the system static, preventing dynamic removals/readings. If the cluster-island value of the cluster nodes web-site.xml is different from the value specified in the LoadBalancer configuration file, it could lead to unexpected behaviour if the LoadBalancer has the cluster node listed for two different islands (a secondary when the cluster node manages to register itself with the LoadBalancer), making it very possible that the clients state is not available on the cluster node. Although new cluster nodes will be added dynamically, the hard coded ones will remain in the list even if they are going down. The feature should be viewed as a useful tool during development and should be avoided in production environments. 14 Balancing HTTPS sites The LoadBalancer can be used to balance back-end sites using SSL. In order to do so the LoadBalancer must be told to use the clients IP for client identification. The reason for this is that the LoadBalancer will pass through the requests without looking into them, as decrypting the message would be too time-consuming.
To use the LoadBalancer to balance back-end sites using SSL the LoadBalancer has to be told to use the clients IP address instead of session ID as identification, as described here. 15 Debugging This section describes common techniques that can be used to debug HTTP-clustering. 15.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 7 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. 16 Troubleshooting This section describes common problems and possible solutions. 16.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. If this issue is encountered during development, it might be usefull to temporarily hardcode the back-ends into the LoadBalancers configuration file as described here. 16.2 Firewall issues Make sure that any firewalls allows for the LoadBalancer to listen to multicast on 230.0.0.2:27512 and that the cluster-enabled Web-modules are allowed to send on the same multicast address/port. Using a simple multicast sender/receiver test application allows for testing the multicast address and make sure that packets can be both sent and received. If this issue is encountered during development, it might be usefull to temporarily hardcode the back-ends into the LoadBalancers configuration file as described here. 16.3 Proxies/Gateways issues As multicast packets are known to bog 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 as well as the LoadBalancer and configure any proxies/gateways accordingly. If this issue is encountered during development, it might be usefull to temporarily hardcode the back-ends into the LoadBalancers configuration file as described here. Copyright © 2005 IronFlare AB |