mod_cluster boasts the following advantages over other httpd-based load balancers:
- Dynamic configuration of httpd workers:
Traditional httpd-based load balancers require explicit configuration of the workers available to a proxy. In mod_cluster, the bulk of the proxy’s configuration resides on the application servers. The set of proxies to which an application server will communicate is determined either by a static list or using dynamic discovery via the advertise mechanism. The application server relays lifecycle events (e.g. server startup/shutdown) to the proxies allowing them to effectively auto-configure themselves. Notably, the graceful shutdown of a server will not result in a fail over response by a proxy, as is the case with traditional httpd-based load balancers.
- Server-side load balance factor calculation
In contrast with traditional httpd-based load balancers, mod_cluster uses load balance factors calculated and provided by the application servers, rather than computing these in the proxy. Consequently, mod_cluster offers a more robust and accurate set of load metrics than is available from the proxy.
- Fine grained web-app lifecycle control
Traditional httpd-based load balancers do not handle web application undeployments particularly well. From the proxy’s perspective requests to an undeployed web application are indistinguishable from a request for an non-existent resource, and will result in 404 errors. In mod_cluster, each server forwards any web application context lifecycle events (e.g. web-app deploy/undeploy) to the proxy informing it to start/stop routing requests for a given context to that server.
- AJP is optional
Unlike mod_jk, mod_cluster does not require AJP. httpd connections to application server nodes can use HTTP, HTTPS, or AJP.
- JBoss AS 5.0.0+ or JBossWeb 2.1.1+
- 2 * httpd servers, with IP’s 192.168.0.1 and 192.168.0.2
- 2 * JBoss 7.1.x servers, with IP’s 10.0.0.1 and 10.0.0.2
What we want to do, is to load balance incoming requests on both httpd instances, to both JBoss backend instances. This gives us dual fail over on either the httpd or JBoss layer.
Steps to configure httpd and JBoss:
- Download latest mod_cluster binary packages: http://www.jboss.org/mod_cluster/downloads.html. If you want to use the httpd binaries provided by your distribution, then download the “dynamic libraries linux2-x64” zip file, otherwise download the “binaries linux2-x64” file
- Extract the contents of the zip file to /etc/httpd/modules/
- Disable the mod_proxy_balancer module in /etc/httpd/conf/httpd.conf, by putting a # in front of it
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
- Enable / load the four modules you extracted, in /etc/httpd/conf/httpd.conf
LoadModule slotmem_module modules/mod_slotmem.so LoadModule manager_module modules/mod_manager.so LoadModule proxy_cluster_module modules/mod_proxy_cluster.so LoadModule advertise_module modules/mod_advertise.so
- Setup a vhost in /etc/httpd/conf/httpd.conf:
AdvertiseFrequency 5 <VirtualHost *:80> ServerName example.com KeepAliveTimeout 5 ManagerBalancerName mydemocluster EnableMCPMReceive <Location /mod_cluster-manager> SetHandler mod_cluster-manager </Location> </VirtualHost>
- Using the standalone-full.xml or standalone-full-ha.xml profiles, ensure you add/modify the proxy-list setting
- Specifying ip:port,ip:port allows multiple httpd instances to be managed by this instance of mod_cluster
- You can now visit: http://192.168.0.1/mod_cluster-manager or http://192.168.0.2/mod_cluster-manager to see the status of each mod_cluster and the direction of load-balancing