Customized Load-Balancing with ZXTM
IntroductionTypically, an application server will start to slow down when it becomes overloaded. Its response times will increase and it will not be able to handle as many connections. ZXTM can easily detect these problems and start directing traffic away from that server. ZXTM's 'Fastest Response Time' and 'Least Connections' algorithms are two examples that will accomplish exactly this task. Sometimes, though, there will be a particular application that just doesn't let on when it is busy. It will soldier on with impeccable response times right up until the server crashes from the excessive load. None of ZXTM's built-in load balancing algorithms would be able to detect this problem until the server has actually crashed. Customized Load-BalancingThis is an ideal situation to use a custom load-balancing algorithm that can gather whatever information it likes and use that to influence where ZXTM will send its requests. In this case, we would like to use the server's CPU utilization so we can tell ZXTM to back off sending requests to a particular server when its resources are running low. The algorithm would therefore be effective regardless of how quickly the server is responding to requests. To create a customized load-balancing algorithm, you can use the Weighted Round Robin algorithm for your pool and then use ZXTM's SOAP API to alter the weighting of each node in that pool depending on how busy it is. You can gather information from the nodes and make SOAP calls from a program running on the same machine as your ZXTM, or on another machine on the network that can access both the SOAP API of your ZXTM and the all nodes in the pool that you want to load balance.
The following is a general outline of what such a program should do:
An ExampleThis is the source code of a simple Perl program that will find out how busy the CPU of each node in the pool is and use that information to determine what the node's priority should be: Perl source code (save as monitorNodes.pl and make it executable) The program takes as arguments the location of the ZXTM's SOAP interface (this will be the same as the location you browse to when accessing the Administration Server), the username and password used to access the SOAP interface and the name of the pool to which you want to apply the custom load-balancing algorithm.
The program has several internal parameters that you can change to customize how requests will be distributed:
When executed, the program will check the pool you specified, get a list of the nodes, obtain the CPU utilization for each of the nodes, calculate the priorities of each node based on that information and then send a command to ZXTM to update the weights of the nodes accordingly! It will continue to monitor the CPU usage of the nodes and will update the weightings once every 5 seconds. SSH CommandsNote that the program uses SSH to run the commands that obtain the CPU utilization for each node. You will have to enter the password for each node every time you start the program unless you configure SSH to allow you to log on without a password. A quick search for 'passwordless ssh' provides plenty of information on how to do this. Alternatively, if you would prefer not to perform the commands using SSH, you could modify the program to listen for information from the nodes on an internet socket. You would then need to run separate programs on each of the nodes that send the desired information to this socket. Once the program has information from all the nodes it can calculate the priorities as before. Comments:This public messageboard is not a forum for technical support. To report technical support problems, please contact our dedicated Support team using the instructions at the bottom of this page.
Comment from:
Eric [Visitor]
· http://www.oraclaris.com
Is it possible to implement election hash via Perl/Java like this?
# Election Hash iRule # Compute Hash - MD5 # # MD5 calculation of Server + URI # Rule selects Server that scores highest # # S = Current high score # N = Node being evaluated # W = Winning node # when HTTP_REQUEST timing on { set S "" foreach N [active_members -list ] { if { [md5 $N[HTTP::uri]] > $S } { set S [md5 $N[HTTP::uri]] set W $N } } pool member [lindex $W 0] [lindex $W 1] } |
Recently...
Other Resources
|

Choosing the right load-balancing algorithm can often be difficult as every web application behaves differently. ZXTM offers a wide variety of built-in load-balancing algorithms to overcome this problem, but if none of these suit your needs then you can just design your own! This article shows you how.




