To use the Web-load balancer:
Define a cluster using either the Management Console or an Ant configuration script. You may optionally define one or more cluster partitions.
To force load balancing of a URL, such as http://my.example.com/MyApp/MyPage, include a load balancing context path prefix, such as “~/MyCluster” or “~/MyPartition”; for example:
http://my.example.com/~/MyCluster/MyApp/MyPage
The tilde (“~”) prefix is the default context path for the wlb Web application. To change this, edit the config/webapp-wlb-user.xml configuration file, run its configure target, then restart the server.
Verify that the server name specified in the load balancing URL resolves to, or is routed to, either a member of the cluster, or a server with the same administrative password. The server name specified in the URL need not resolve to the same server every time; for example, you can use a round-robin distribution policy.
The Web-load balancer selects one active server in the cluster (or partition). A “weighted-random” algorithm is used. Three servers (or fewer, if three are not available) are randomly selected from the cluster (or partition) and the least loaded of the selected servers is the target of the HTTP redirect, with the load-balancing context path prefix removed from the URL. An example of a resolved URL is:
http://server27.example.com/MyApp/MyPage
Where “http://server27.example.com” is the primary HTTP listener for the selected application server. If your application server has multiple HTTP listeners, a port number is selected if it matches the port number (modulo 10) of the initial load-balancing URL. For example, if a server has two HTTP listeners:
http://server27.example.com:80
https://server27.example.com:443
the load-balancing URL “http://my.example.com/~/MyCluster/MyApp/MyPage” might resolve to “http://server27.example.com:80/MyApp/MyPage.” Whereas the load- balancing URL “https://my.example.com:443/~/MyCluster/MyApp/MyPage” might resolve to “https://server27.example.com:443/MyApp/MyPage.” If unspecified, the port number in a URL defaults to 80 for HTTP and 443 for HTTPS.
Once a redirect is performed, the load balancer is not involved in subsequent requests, unless the Web application at the target URL delivers pages that include a load-balancing context path prefix.
If the target Web application is not distributable, and uses HTTP sessions, the Web-load balancer should be used only before a Web session is created. Otherwise, an HTTP redirect from the server might occur, in which a Web session is established to a server that does not exist in the Web session.
HTML pages delivered by the target Web application should
use relative paths (without the http://my.example.com
prefix). If absolute paths are used in links, the server selected
by the Web-load balancer is not used for a link with an
absolute path, unless the absolute path includes a load balancing
context path prefix. Frequent use of the load balancer degrades
performance, compared with using it only when a session is established.
The server name used in a load-balancing URL (for example, my.example.com) could become a single point of failure in your system, unless you use an external mechanism (hardware redirector or DNS round robin) to ensure that initial (preload balancing) requests are protected from a single point of failure.