How to use the Load Balancing feature in Sun Cluster
By dlnprasad on Feb 02, 2007
Do you know that Sun Cluster provides a Load Balancing feature in addition to High Availability? This is a cool feature where you can configure the applications/data services to run on multiple systems simultaneously with existing cluster hardware. Yes, there is no need to add extra hardware for achieving this IP-based load balancing.
Most of the applications that can be highly-available can also be configured as scalable with a few extra requirements described in this document. If your application meets the above requirements, then you are ready to configure the scalable application with few simple steps
Here are the instructions:
Apache is used as an example application to demonstrate how easily the Load Balancing feature can be enabled with Sun Cluster. Below examples show the new CLI available in sc3.2, however the same can be achieved with equivalent old CLI available in previous releases.Register the Resource Type:
To configure a scalable resource, the RTR file should declare the Scalable property and also set FAILOVER property to false . If you are using existing data service packages to configure the scalable resource, make sure the above settings are true. Otherwise, reset the values and update the packages.
# clrt register SUNW.apache
Configure the Shared Address resource:
# clresourcegroup create shared-rg
# clressharedaddress create -g shared-rg octet-1
# clresourcegroup online -M apache-rg
This example assumes that IP address is already configured for host name octet-1.
Create the scalable resource group:
# clresourcegroup create -S apache-rg
Create the scalable resource:
Here are the descriptions of few properties of interest:
- Scalable: TRUE specifies the resource to be scalable, which enables the network framework responsible for load balancing.
- Port_list: List of port numbers where the server is listening.
- Load_balancing_policy: This value is used in deciding how the load will be distributed across the nodes. The options are:
- LB_WEIGHTED: Load will be distributed based on weights specified using the Load_balancing_weights property.
- LB_STICKY: Load will be distributed based on the client's IP address. In this case, the set of ports is known during the configuration and all the requests coming from the same client IP address will be distributed to the same node listening on this predefined port.
- LB_STICKY_WILD: Load will be distributed based on the client's IP address and in this case the ports are not known in advance and are assigned dynamically. Here, all the requests coming from the same client will go to the same node regardless of the port number to which that IP address is coming.
# clresource create -g apache-rg -t SUNW.apache \\
-p resource_dependencies=octet-1 -p Port_list=80/tcp \\
-p scalable=true -p bin_dir=/usr/apache/bin \\
-p Load_balancing_policy=LB_STICKY apache-rs
For detailed descriptions of the above properties or other scalable properties, see this document.
Bring the resource group online
# clresourcegroup online -M apache-rg
Check the status of the resources:
# clresource status
=== Cluster Resources ===
Resource Name Node Name State Status Message
--------------------- ------------------ -------- ---------------------
shared-ip poctet1 Online Online - SharedAddress online.
poctet2 Offline Offline
poctet3 Offline Offline
poctet4 Offline Offline
apache-rs poctet1 Online Online - Service is online.
poctet2 Online Online - Service is online.
poctet3 Online Online - Service is online.
poctet4 Online Online - Service is online.
That's it, you are ready to use Sun Cluster with Load balancing.
Now, you can observe the client requests getting distributed across the nodes according to the load_balancing_policy.
Sun Cluster Engineering