The newly discovered Apache module mod_cluster seems to offer many advantages compared to mod_jk which could be used in the new Apache/Jboss environment.

The following features are listed:
– Dynamic configuration of httpd workers
– Server-side load balance factor calculation
– Fine grained web-app lifecycle control
– AJP is optional
– Compatible staring at JBoss 4.2.x onwards

Other useful links:
http://www.jboss.org/mod_cluster
http://anonsvn.jboss.org/repos/mod_cluster/tags/release/
http://docs.jboss.org/mod_cluster/1.2.0/html/

Start-up Instructions are found at:
http://docs.jboss.org/mod_cluster/1.2.0/html/Quick_Start_Guide.html#d0e357

TESTING Environment:
List of components of a test environment:
1 VM with Newly compiled Apache & mod_cluster
2 VMs with identical JBoss application

Created three VMs as follows:
Hostname Function IP HTTP-Port AJP-Port
testweb APACHE 192.168.100.1 80 n/a
backend1 JVM1 192.168.100.2 6003 6001
backend2 JVM2 192.168.100.3 6003 6001

Manual testing of direct access to backends:
http://backend1.mydomain.srv:6003/sysnode/
http://backend2.mydomain.srv:6003/sysnode/

Create new Apache vhost as follows:
########################
# Relevant part of httpd.conf
#######################
# Extra modules needed for mod_cluster
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule slotmem_module modules/mod_slotmem.so
LoadModule manager_module modules/mod_manager.so
LoadModule advertise_module modules/mod_advertise.so

Adding to the content of /etc/hosts
192.168.100.1 vhost-01
Content of vhosts.conf
LogLevel debug
Listen vhost-01:80
NameVirtualHost vhost-01:80
#
#------------ Directives for mod_cluster only---------------
<ifmodule proxy_cluster_module>
# Displays the first 100 sessions IDs in manager interface
# Turn on the session ID display of 100 in the mod_cluster-manager page
MaxsessionId 10000
CreateBalancers 2
MaxContext 10000
</ifmodule>
#
# ------ Build the MCPM Connector and advertize connector on Web server
<ifmodule manager_module>
Listen vhost-01:8081
<Virtualhost vhost-01:8081>
# MCPM configuration
KeepAliveTimeout 60
MaxKeepAliveRequests 0
EnableMCPMReceive
#
CustomLog /www/http_logs/MCPM_connector_acc.log j_common
ErrorLog /www/http_logs/MCPM_connector_err.log
</virtualhost>
</ifmodule>
#
#---------- Managemant console interface ----------------------
<ifmodule manager_module>
Listen vhost-01:8000
<Virtualhost vhost-01:8000>
# mod_cluster Manager interface
<Location /mcm>
SetHandler mod_cluster-manager
Order deny,allow
Deny from all
Allow from env=IP_ALLOWED
# Displays verbose extra info about the mod_cluster config
AllowDisplay On
</Location>
CustomLog /www/http_logs/cluster_manager_acc.log j_common
ErrorLog /www/http_logs/cluster_manager_err.log
</virtualhost>
</ifmodule>
#
# --------------------- CLIENT Virtual Host 1----------------------------
#
# http://test1.mydomain.srv
<Virtualhost vhost-01:80>
ServerName test1.mydomain.srv
DocumentRoot /www/htdocs1
#
#------------ Directives for mod_cluster ---------------
<ifmodule proxy_cluster_module>
ProxyRequests Off
UseCanonicalName On
ProxyPreserveHost On
# Allowing all proxy requests
<proxy balancer://jboss.web1>
AddDefaultCharset off
Order deny,allow
Allow from All
</proxy>
ProxyPass / balancer://jboss.web1/ stickysession=JSESSIONID|jsessionid nofailover=On
ProxyPassReverse / balancer://jboss.web1/
</ifmodule>
#
CustomLog /www/http_logs/test1.mydomain.srv_acc.log j_common
ErrorLog /www/http_logs/test1.mydomain.srv_err.log
</virtualhost>
#
# --------------------- CLIENT Virtual Host 2----------------------------
# http://test2.mydomain.srv
<virtualhost vhost-01:80>
ServerName test2.mydomain.srv
DocumentRoot /www/htdocs2
#
#------------ Directives for mod_cluster ---------------
<ifmodule proxy_cluster_module>
ProxyRequests Off
UseCanonicalName On
ProxyPreserveHost On
# Allowing all proxy requests
<proxy balancer://jboss.web2>
AddDefaultCharset off
Order deny,allow
Allow from All
</proxy>
ProxyPass / balancer://jboss.web2/ stickysession=JSESSIONID|jsessionid nofailover=On
ProxyPassReverse / balancer://jboss.web2/
</ifmodule>
#
CustomLog /www/http_logs/test2.mydomain.srv_acc.log j_common
ErrorLog /www/http_logs/test2.mydomain.srv_err.log
</virtualhost>

The mod-cluster have now been tested with the following conditions:
– When an app is finished starting-up, it takes about 3-5 sec before Apache has registered the APP
– The requests sent to Apache were then well balanced between the registered APPs and sent to vhost-asigned APPs custer.

Live upgrade a backend APP servers:
Register all 4 APPs to the same cluster and test how the registration of new APPs and de-registration of running APPs is performing.

Method suggested to do an APP upgrade.
– Start the new apps and wait till they are all up and well running.
– New requests will be directed to old and new apps.
– Disable gracefully the old apps from within the management console. This will stop new requests from going to old apps.
– From this point all new requests will only be sent to the new apps.
– Then the number of still open connections to old apps will be dynamically go shown untill the old apps don’t get any new requests.
– When these numbers for all old apps are down to ‘0’ then you can take the old apps down.

NOTE 1:
During test we had problems to redirect old SSID to new nodes when the old node serving the SSID was not any more available.
The mod_cluster was creating a ‘Service unavailable’ error.

To fix this the following JBOSS properties(postSetEnv.sh) have been set:
export JAVA_OPTS="${JAVA_OPTS} -Djboss.mod_cluster.stickySessionRemove=true"
export JAVA_OPTS="${JAVA_OPTS} -Djboss.mod_cluster.stickySessionForce=false"

Here is the full set of properties related to mod_cluster:
export JAVA_OPTS="${JAVA_OPTS} -Djboss.mod_cluster.balancer=jboss.web1"
(value here has to be modified to a node name variable)
export JAVA_OPTS="${JAVA_OPTS} -Djboss.mod_cluster.proxyList=192.168.100.1:8081"
(values to be set to the proper web server's internal LAN IP)

FIXED VALUES
export JAVA_OPTS="${JAVA_OPTS} -Djboss.mod_cluster.enable=true"
export JAVA_OPTS="${JAVA_OPTS} -Djboss.mod_cluster.advertise=false"
export JAVA_OPTS="${JAVA_OPTS} -Djboss.mod_cluster.excludedContexts="
export JAVA_OPTS="${JAVA_OPTS} -Djboss.mod_cluster.stickySessionRemove=true"
export JAVA_OPTS="${JAVA_OPTS} -Djboss.mod_cluster.stickySessionForce=false"