Mod Cluster UserGuide
Mod Cluster UserGuide
1. Overview ...................................................................................................................... 1.1. Platforms ............................................................................................................ 1.2. Advantages ........................................................................................................ 1.3. Requirements ..................................................................................................... 1.4. Limitations .......................................................................................................... 1.5. Downloads ......................................................................................................... 1.6. Configuration ...................................................................................................... 1.7. Migration ............................................................................................................ 1.8. SSL support ....................................................................................................... 1.9. Load Balancing Demo Application ....................................................................... 2. Quick Start Guide ........................................................................................................ 2.1. Download mod_cluster components ..................................................................... 2.2. Install the httpd binary ........................................................................................ 2.2.1. Install the whole httpd .............................................................................. 2.2.2. Install only the modules ............................................................................ 2.2.3. Install in home directory ........................................................................... 2.2.4. Install in Windows ....................................................................................
1 1 1 2 2 3 3 3 4 4 5 5 5 5 5 6 6
2.3. Configure httpd ................................................................................................... 7 2.4. Install the server-side binaries ............................................................................. 8 2.4.1. Installing in JBoss AS 6.x ......................................................................... 8 2.4.2. Installing in JBoss AS 5.x ......................................................................... 8 2.4.3. Installing in JBoss Web or Tomcat ............................................................ 8 2.4.4. Installing in JBoss AS 4.2.x or 4.3.x .......................................................... 9 2.5. Configuring the server-side .................................................................................. 9 2.5.1. Configuring mod_cluster with JBoss AS 5.x+ ............................................. 9 2.5.2. Configuring mod_cluster with standalone JBoss Web or Tomcat .................. 9 2.5.3. Integrate mod_cluster with JBoss AS 4.2.x and 4.3.x .................................. 9 2.6. Start httpd .......................................................................................................... 9 2.7. Start the back-end server .................................................................................. 10 2.7.1. Starting JBoss AS .................................................................................. 10 2.7.2. Starting JBossWeb or Tomcat ................................................................. 10 2.8. Set up more back-end servers ........................................................................... 10 2.9. Experiment with the Load Balancing Demo Application ........................................ 10 3. httpd configuration .................................................................................................... 11 3.1. Apache httpd configuration ................................................................................ 11 3.2. mod_proxy configuration ................................................................................... 11 3.3. mod_slotmem configuration ............................................................................... 11 3.4. mod_proxy_cluster ............................................................................................ 12 3.4.1. CreateBalancers ..................................................................................... 12 3.4.2. UseAlias ................................................................................................ 12 3.4.3. LBstatusRecalTime ................................................................................. 12 3.4.4. ProxyPassMatch/ProxyPass .................................................................... 13 3.5. mod_manager ................................................................................................... 13 3.5.1. MemManagerFile ................................................................................... 13
iii
mod_cluster Documentation
3.5.2. Maxcontext ............................................................................................ 3.5.3. Maxnode ................................................................................................ 3.5.4. Maxhost ................................................................................................. 3.5.5. Maxsessionid ......................................................................................... 3.5.6. ManagerBalancerName .......................................................................... 3.5.7. PersistSlots ............................................................................................ 3.5.8. CheckNonce .......................................................................................... 3.5.9. AllowDisplay .......................................................................................... 3.5.10. AllowCmd ............................................................................................ 3.5.11. ReduceDisplay ..................................................................................... 3.5.12. SetHandler mod_cluster-manager .......................................................... 3.6. mod_advertise .................................................................................................. 3.6.1. ServerAdvertise ...................................................................................... 3.6.2. AdvertiseGroup ...................................................................................... 3.6.3. AdvertiseFrequency ................................................................................ 3.6.4. AdvertiseSecurityKey .............................................................................. 3.6.5. AdvertiseManagerUrl .............................................................................. 3.6.6. AdvertiseBindAddress ............................................................................. 3.7. Minimal Example .............................................................................................. Building httpd modules ............................................................................................. 4.1. Build a patched httpd from it sources ................................................................. 4.2. Build the 4 modules of mod_cluster ................................................................... 4.3. Build the mod_proxy module ............................................................................. Installing httpd modules ............................................................................................ 5.1. Configuration .................................................................................................... 5.2. Installing and using the bundles ......................................................................... Server-side Configuration .......................................................................................... 6.1. JBoss AS ......................................................................................................... 6.1.1. Non-clustered mode ............................................................................... 6.1.2. Clustered mode ...................................................................................... 6.1.3. Configuration Properties ......................................................................... 6.1.4. Connectors ............................................................................................ 6.1.5. Node Identity ......................................................................................... 6.2. JBoss Web & Tomcat ....................................................................................... 6.2.1. Lifecycle Listener ................................................................................... 6.2.2. Additional Tomcat dependencies ............................................................. 6.3. Migrating from 1.0.x .......................................................................................... 6.3.1. Dependency with JBoss Web .................................................................. 6.3.2. server.xml .............................................................................................. 6.3.3. mod_cluster-jboss-beans.xml .................................................................. AS7 modcluster subsystem Configuration ................................................................ 7.1. ModCluster Subsystem in JBoss AS7 ................................................................ 7.2. ModCluster Subsystem minimal configuration ..................................................... 7.3. ModCluster Subsystem configuration ..................................................................
13 13 14 14 14 14 14 14 14 15 15 17 17 17 17 17 17 18 18 19 19 19 20 21 21 21 23 23 23 24 25 26 26 26 27 27 27 27 27 28 29 29 29 29
4.
5.
6.
7.
iv
7.3.1. mod-cluster-config Attributes ................................................................... 7.3.2. simple-load-provider Attributes ................................................................ 7.3.3. dynamic-load-provider Attributes ............................................................. 7.3.4. load-metric Configuration ........................................................................ 7.3.5. custom-load-metric Configuration ............................................................ 8. Building Server-Side Components ............................................................................. 8.1. Requirements ................................................................................................... 8.2. Building ............................................................................................................ 8.3. Build Artifacts ................................................................................................... 9. Server-side Configuration Properties ........................................................................ 9.1. Proxy Discovery Configuration ........................................................................... 9.2. Proxy Configuration ........................................................................................... 9.3. SSL Configuration ............................................................................................. 9.4. HA Configuration .............................................................................................. 9.5. Load Configuration for JBoss Web and Tomcat .................................................. 10. Server-Side Load Metrics ......................................................................................... 10.1. Web Container metrics .................................................................................... 10.1.1. ActiveSessionsLoadMetric ................................................................. 10.1.2. BusyConnectorsLoadMetric ................................................................. 10.1.3. ReceiveTrafficLoadMetric ................................................................. 10.1.4. SendTrafficLoadMetric ...................................................................... 10.1.5. RequestCountLoadMetric .................................................................... 10.2. System/JVM metrics ........................................................................................ 10.2.1. AverageSystemLoadMetric .................................................................. 10.2.2. SystemMemoryUsageLoadMetric ........................................................... 10.2.3. HeapMemoryUsageLoadMetric ............................................................... 10.3. Other metrics .................................................................................................. 10.3.1. ConnectionPoolUsageLoadMetric ........................................................ 11. Installing Server-Side Components ......................................................................... 11.1. Installing in JBoss AS 6.0.0.M1 and up ............................................................ 11.2. Installing in JBoss AS 5.x ................................................................................ 11.3. Installing in JBoss Web or Tomcat ................................................................... 11.4. Installing in JBoss AS 4.2.x or 4.3.x ................................................................. 12. Using SSL in mod_cluster ....................................................................................... 12.1. Using SSL between JBossWEB and httpd ........................................................ 12.1.1. Apache httpd configuration part ............................................................. 12.1.2. ClusterListener configuration part .......................................................... 12.1.3. mod-cluster-jboss-beans configuration part ............................................. 12.1.4. How the diferent files were created ........................................................ 12.2. Using SSL between httpd and JBossWEB ........................................................ 12.2.1. How the diferent files were created ........................................................ 12.3. Forwarding SSL browser informations when using http/https between httpd and JBossWEB .............................................................................................................. 13. Migration from mod_jk .............................................................................................
29 30 30 31 31 33 33 33 33 35 35 38 41 43 43 45 46 46 47 47 48 49 49 49 50 50 51 51 53 53 53 53 53 55 55 55 55 56 56 58 59 60 61
mod_cluster Documentation
14. Migration from mod_proxy ...................................................................................... 14.1. Workers .......................................................................................................... 14.2. Balancers ....................................................................................................... 15. Load Balancing Demo Application ........................................................................... 15.1. Overview ........................................................................................................ 15.2. Basic Usage ................................................................................................... 15.3. Client Driver Configuration Options .................................................................. 15.4. Load Generation Scenarios ............................................................................. 16. Change Log ............................................................................................................. 16.1. 1.1.3.Final (12 August 2011) ............................................................................ 16.2. 1.1.2.Final (21 April 2011) ............................................................................... 16.3. 1.1.1.Final (31 January 2011) .......................................................................... 16.4. 1.1.0.Final (13 August 2010) ............................................................................ 16.5. 1.1.0.CR3 (15 June 2010) ............................................................................... 16.6. 1.1.0.CR2 (11 May 2010) ................................................................................ 16.7. 1.1.0.CR1 (22 March 2010) ............................................................................. 16.8. 1.1.0.Beta1 (30 October 2009) ......................................................................... 17. Frequently Asked questions .................................................................................... 17.1. What is Advertise ............................................................................................ 17.2. What to do if I don't want to use Advertise (multicast): ....................................... 17.3. I am using Tomcat 7 / 6 what should I do: ........................................................ 17.4. It is not working what should I do: .................................................................... 17.4.1. No error ............................................................................................... 17.4.2. Error in server.log or catalina.out ........................................................... 17.4.3. Error in error_log ..................................................................................
63 63 64 67 67 67 69 71 75 75 75 76 77 77 78 79 80 83 83 83 84 84 84 86 88
vi
Chapter 1.
Overview
mod_cluster is an httpd-based load balancer. Like mod_jk and mod_proxy, mod_cluster uses a communication channel to forward requests from httpd to one of a set of application server nodes. Unlike mod_jk and mod_proxy, mod_cluster leverages an additional connection between the application server nodes and httpd. The application server nodes use this connection to transmit server-side load balance factors and lifecycle events back to httpd via a custom set of HTTP methods, affectionately called the Mod-Cluster Management Protocol (MCMP). This additional feedback channel allows mod_cluster to offer a level of intelligence and granularity not found in other load balancing solutions. Within httpd, mod_cluster is implemented as a set of modules for httpd with mod_proxy enabled. Much of the logic comes from mod_proxy, e.g. mod_proxy_ajp provides all the AJP logic needed by mod_cluster.
1.1. Platforms
JBoss already prepares binary packages [http://www.jboss.org/mod_cluster/downloads.html] with httpd and mod_cluster so you can quickly try mod_cluster on the following platforms:
Linux x86, x64, ia64 Solaris x86, SPARC Windows x86, x64, ia64 HP-UX PA-RISC, ia64
1.2. Advantages
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 failover 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.
Chapter 1. Overview
Consequently, mod_cluster offers a more robust and accurate set of load metrics than is available from the proxy. See the chapter entitled Server-Side Load Metrics for details. 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. The original concepts are described in a wiki [http://www.jboss.org/community/docs/DOC-11431].
1.3. Requirements
httpd-2.2.8+ JBoss AS 5.0.0+ or JBossWeb 2.1.1+
Note
httpd-2.2.8+ is already in the bundles, so if you use the bundle you don't need to download Apache httpd.
1.4. Limitations
mod_cluster uses shared memory to keep the nodes description, the shared memory is created at the start of httpd and the structure of each item is fixed. The following can't be changed by configuration directives. Max Alias length 40 characters (Host: hostname header, Alias in <Host/>). Max context length 40 (for example myapp.war deploys in /myapp /myapp is the context). Max balancer name length 40 (balancer property in mbean). Max JVMRoute string length 80 (JVMRoute in <Engine/>). Max load balancing group name length 20 (domain property in mbean). Max hostname length for a node 64 (address in the <Connector/>). Max port length for a node 7 (8009 is 4 characters, port in the <Connector/>).
Downloads
Max scheme length for a node 6 (possible values are http, https, ajp, liked with the protocol of <Connector/>). Max cookie name 30 (the header cookie name for sessionid default value: JSESSIONID from org.apache.catalina.Globals.SESSION_COOKIE_NAME). Max path name 30 (the parameter name for the sessionid default value: jsessionid from org.apache.catalina.Globals.SESSION_PARAMETER_NAME). Max length for a sessionid BE81FAA969BF64C8EC2B6600457EAAAA.node01). 120 (something like
1.5. Downloads
Download the latest mod_cluster release here [http://www.jboss.org/mod_cluster/downloads/ latest]. The release is comprised of the following artifacts:
httpd binaries for common platforms JBoss AS/JBossWeb/Tomcat binary distribution Alternatively, you can build from source using the subversion repository: http://anonsvn.jboss.org/repos/mod_cluster/tags/release/ mod_cluster/tags/] [http://anonsvn.jboss.org/repos/
1.6. Configuration
If you want to skip the details and just set up a minimal working installation of mod_cluster, see the Quick Start Guide.
1.7. Migration
Migrating from mod_jk or mod_proxy is fairly straight forward. In general, much of the configuration previously found in httpd.conf is now defined in the application server nodes.
Chapter 1. Overview
Chapter 2.
That will give you a full httpd install in your /opt/jboss directory.
And then you have to copy the files below to you module directory:
mod_proxy.so
cd httpd-2.2\bin installconf.bat
httpd.exe
httpd.exe -k install
httpd.exe -k start
Configure httpd
Note that in the windows bundles have a flat directory structure, so you have httpd-2.2/modules/ instead of opt/jboss/httpd/lib/httpd/modules.
LoadModule proxy_module /opt/jboss/httpd/lib/httpd/modules/mod_proxy.so LoadModule proxy_ajp_module /opt/jboss/httpd/lib/httpd/modules/mod_proxy_ajp.so LoadModule slotmem_module /opt/jboss/httpd/lib/httpd/modules/mod_slotmem.so LoadModule manager_module /opt/jboss/httpd/lib/httpd/modules/mod_manager.so LoadModule proxy_cluster_module /opt/jboss/httpd/lib/httpd/modules/mod_proxy_cluster.so LoadModule advertise_module /opt/jboss/httpd/lib/httpd/modules/mod_advertise.so Listen 10.33.144.3:6666 <VirtualHost 10.33.144.3:6666> <Directory /> Order deny,allow Deny from all Allow from 10.33.144. </Directory> KeepAliveTimeout 60 MaxKeepAliveRequests 0 ManagerBalancerName mycluster AdvertiseFrequency 5 </VirtualHost>
If you are using your own install of httpd, httpd.conf is found in your install's conf directory. The content to add to httpd.conf is slightly different from the above (different path to the various .so files):
LoadModule proxy_module modules/mod_proxy.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 proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule advertise_module modules/mod_advertise.so Listen 10.33.144.3:6666 <VirtualHost 10.33.144.3:6666> <Directory /> Order deny,allow Deny from all Allow from 10.33.144. </Directory> KeepAliveTimeout 60 MaxKeepAliveRequests 0 ManagerBalancerName mycluster AdvertiseFrequency 5 </VirtualHost>
cp -r /tmp/mod-cluster/mod-cluster.sar $JBOSS_HOME/server/all/deploy
cp -r /tmp/mod-cluster/JBossWeb-Tomcat/lib/*
$CATALINA_HOME/lib/
/opt/jboss/httpd/sbin/apachectl start
10
Chapter 3.
httpd configuration
3.1. Apache httpd configuration
You need to load the modules that are needed for mod_cluster for example:
LoadModule proxy_module modules/mod_proxy.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 proxy_cluster_module modules/mod_proxy_cluster.so LoadModule advertise_module modules/mod_advertise.so
mod_proxy and mod_proxy_ajp are standard httpd modules. mod_slotmem is a shared slotmem memory provider. mod_manager is the module that reads information from JBoss AS/JBossWeb/ Tomcat and updates the shared memory information. mod_proxy_cluster is the module that contains the balancer for mod_proxy. mod_advertise is an additional module that allows httpd to advertise via multicast packets the IP and port where the mod_cluster is listening. This multimodule architecture allows the modules to easily be changed depending on what the customer wants to do. For example when using http instead of AJP, only
11
3.4. mod_proxy_cluster
3.4.1. CreateBalancers
CreateBalancers: Define how the balancer are created in the httpd VirtualHosts, this is to allow directives like:
ProxyPass / balancer://mycluster1/
0: Create in all VirtualHosts defined in httpd. 1: Don't create balancers (requires at least one ProxyPass/ProxyPassMatch to define the balancer names). 2: Create only the main server. Default: 2 Note: When using 1 don't forget to configure the balancer in the ProxyPass directive, because the default is empty stickysession and nofailover=Off and the values received via the MCMP CONFIG message are ignored.
3.4.2. UseAlias
UseAlias: Check that the Alias corresponds to the ServerName (See Host Name Aliases [http:// labs.jboss.com/file-access/default/members/jbossweb/freezone/docs/latest/config/host.html]) 0: Don't (ignore Aliases) 1: Check it Default: 0 Ignore the Alias information from the nodes.
3.4.3. LBstatusRecalTime
LBstatusRecalTime: Time interval in seconds for loadbalancing logic to recalculate the status of a node Default: 5 seconds The actual formula to recalculate the status of a node is:
lbfactor is received for the node via STATUS messages.lbstatus is recalculated every LBstatusRecalTime seconds using the formula:
12
ProxyPassMatch/ProxyPass
elected is the number of time the worker was elected.oldelected is elected last time the lbstatus was recalculated.The node with the lowest status is selected. Nodes with lbfactor # 0 are skipped by the both calculation logic.
3.4.4. ProxyPassMatch/ProxyPass
ProxyPassMatch/ProxyPass: ProxyPassMatch and ProxyPass are mod_proxy directives that when using ! (instead the back-end url) prevent to reverse-proxy in the path. This could be used allow httpd to serve static information like images.
ProxyPassMatch ^(/.*\.gif)$ !
The above for example will allow httpd to server directly the .gif files.
3.5. mod_manager
The Context of a mod_manger directive is VirtualHost except mentioned otherwise. server config means that it must be outside a VirtualHost configuration. If not an error message will be displayed and httpd won't start.
3.5.1. MemManagerFile
MemManagerFile: That is the base name for the names mod_manager will use to store configuration, generate keys for shared memory or lock files. That must be an absolute path name; the directories will created if needed. It is highly recommended that those files are placed on a local drive and not an NFS share. (Context: server config) Default: $server_root/logs/
3.5.2. Maxcontext
Maxcontext: That is the number max of contexts supported by mod_cluster. (Context: server config) Default: 100
3.5.3. Maxnode
Maxnode: That is the number max nodes supported by mod_cluster. (Context: server config) Default: 20
13
3.5.4. Maxhost
Maxhost: That is the number max host (Aliases) supported by mod_cluster. That is also the max number of balancers. (Context: server config) Default: 10
3.5.5. Maxsessionid
Maxsessionid: That is the number of active sessionid we store to give number of active sessions in the mod_cluster-manager handler. A session is unactive when mod_cluster doesn't receive any information from the session in 5 minutes. (Context: server config) Default: 0 (the logic is not activated).
3.5.6. ManagerBalancerName
ManagerBalancerName: That is the name of balancer to use when the JBoss AS/JBossWeb/ Tomcat doesn't provide a balancer name. Default: mycluster
3.5.7. PersistSlots
PersistSlots: Tell mod_slotmem to persist the nodes, Alias and Context in files. (Context: server config) Default: Off
3.5.8. CheckNonce
CheckNonce: Switch check of nonce when using mod_cluster-manager handler on | off Since 1.1.0.CR1 Default: on Nonce checked
3.5.9. AllowDisplay
AllowDisplay: Switch additional display on mod_cluster-manager main page on | off Since 1.1.0.GA Default: off Only version displayed
3.5.10. AllowCmd
AllowCmd: Allow commands using mod_cluster-manager URL on | off Since 1.1.0.GA
14
ReduceDisplay
3.5.11. ReduceDisplay
ReduceDisplay - Reduce the information the main mod_cluster-manager page to allow more nodes in the page. on | off Default: off Full information displayed
<Location /mod_cluster-manager> SetHandler mod_cluster-manager Order deny,allow Deny from all Allow from 127.0.0.1 </Location>
When accessing the location you define in httpd.conf you get something like:
15
Note that: Transferred: Corresponds to the POST data send to the back-end server. Connected: Corresponds to the number of requests been processed when the mod_cluster status page was requested. sessions: Corresponds to the number of sessions mod_cluster report as active (on which there was a request during the past 5 minutes). That field is not present when Maxsessionid is zero.
16
mod_advertise
3.6. mod_advertise
mod_advertise uses multicast packets to advertise the VirtualHost where it is configured that must be the same VirtualHost where mod_manager is defined. Of course at least one mod_advertise must be in the VirtualHost to allow mod_cluster to find the right IP and port to give to the ClusterListener.
3.6.1. ServerAdvertise
ServerAdvertise On: Use the advertise mechanism to tell the JBoss AS/JBossWeb/Tomcat to whom it should send the cluster information. ServerAdvertise On http://hostname:port: Tell the hostname and port to use. Only needed if the VirtualHost is not defined correctly, if the VirtualHost is a Name-based Virtual Host [http:// httpd.apache.org/docs/2.2/vhosts/name-based.html] or when VirtualHost is not used. ServerAdvertise Off: Don't use the advertise mechanism. Default: Off. (Any Advertise directive in a VirtualHost sets it to On in the VirtualHost)
3.6.2. AdvertiseGroup
AdvertiseGroup IP:port: That is the multicast address to use (something like 232.0.0.2:8888 for example). IP should correspond to AdvertiseGroupAddress and port to AdvertisePort in the JBoss AS/JBossWeb/Tomcat configuration. Note that if JBoss AS is used and the -u startup switch is included in the AS startup command, the default AdvertiseGroupAddress is the value passed via the -u. If port is missing the default port will be used: 23364. Default: 224.0.1.105:23364.
3.6.3. AdvertiseFrequency
AdvertiseFrequency seconds[.miliseconds]: Time between the multicast messages advertising the IP and port. Default: 10 Ten seconds.
3.6.4. AdvertiseSecurityKey
AdvertiseSecurityKey value: key string to identify the mod_cluster in JBossWEB. Default: No default value. Information not sent.
3.6.5. AdvertiseManagerUrl
AdvertiseManagerUrl value: Not used in this version (It is sent in the X-Manager-Url: value header). That is the URL that JBoss AS/JBossWeb/Tomcat should use to send information to mod_cluster
17
3.6.6. AdvertiseBindAddress
AdvertiseBindAddress IP:port: That is the address and port httpd is bind to send the multicast messages. This allow to specify an address on multi IP address boxes. Default: 0.0.0.0:23364
18
Chapter 4.
./configure --prefix=apache_installation_directory \ --with-mpm=worker \ --enable-mods-shared=most \ --enable-maintainer-mode \ --with-expat=builtin \ --enable-ssl \ --enable-proxy \ --enable-proxy-http \ --enable-proxy-ajp \ --disable-proxy-balancer
19
Build the mod_cluster modules components, for each subdirectory advertise, mod_manager, mod_proxy_cluster and mod_slotmem do something like:
Where apache_installation_directory is the location of an installed version of httpd-2-2.x. NOTE: You can ignore the libtool message on most platform:
20
Chapter 5.
5.1. Configuration
A minimal configuration is needed in httpd (See httpd.conf). A listener must be a added in in JBossWEB conf/server.xml (See Configuring JBoss AS/Web).
The httpd.conf is located in /opt/jboss/httpd/httpd/conf to quick test just add something like:
Listen 10.33.144.3:6666 <VirtualHost 10.33.144.3:6666> <Directory /> Order deny,allow Deny from all Allow from 10.33.144. </Directory> KeepAliveTimeout 60 MaxKeepAliveRequests 0 ManagerBalancerName mycluster AdvertiseFrequency 5 </VirtualHost>
21
/opt/jboss/httpd/sbin/apachectl start
22
Chapter 6.
Server-side Configuration
6.1. JBoss AS
mod_cluster is supported in AS7 via the modcluster subsystem See AS7. In other AS version mod_cluster's configuration resides within the following file:
$JBOSS_HOME/server/$PROFILE/deploy/mod_cluster.sar/META-INF/mod_cluster-jbossbeans.xml file.
The entry point for mod_cluster's server-side configuration is the ModClusterListener bean, which delegates web container (i.e. JBoss Web) specific events to a container agnostic event handler. In general, the ModClusterListener bean defines:
1. A ContainerEventHandler in which to handle events from the web container. There are two available implementations, the choice of which dictates the mode in which mod_cluster will operate: clustered or non-clustered. 2. A reference to the JBoss mbean server. e.g.
<bean name="ModClusterListener" class="org.jboss.modcluster.catalina.CatalinaEventHandlerAdapter"> <constructor> <parameter class="org.jboss.modcluster.ContainerEventHandler"> <inject bean="ModClusterService"/><!-- Non-clustered mode --> <!--inject bean="HAModClusterService"/--><!-- Clustered mode --> </parameter> <parameter class="javax.management.MBeanServer"> <inject bean="JMXKernel" property="mbeanServer"/> </parameter> </constructor> </bean>
23
In general, the ModClusterService bean defines: 1. An object containing mod_cluster's configuration properties. 2. An object responsible for calculating the load balance factor for this node. This is described in detail in the chapter entitled Server-Side Load Metrics. e.g.
annotation> <constructor> <parameter class="org.jboss.modcluster.config.ModClusterConfig"> <inject bean="ModClusterConfig"/> </parameter> <parameter class="org.jboss.modcluster.load.LoadBalanceFactorProvider"> <inject bean="DynamicLoadBalanceFactorProvider"/> </parameter> </constructor> </bean>
24
Configuration Properties
In general, HAModClusterService defines: 1. An object containing mod_cluster's configuration properties. 2. An object responsible for calculating the load balance factor for this node. This is described in detail in the chapter entitled Server-Side Load Metrics. 3. An HAPartition, the JBoss clustering group communication building block. The default HAPartition is defined in: $JBOSS_HOME/server/$PROFILE/deploy/cluster/hapartitionjboss-beans.xml
4. A policy for determining which group member should be designated as the singleton master. e.g.
annotation> <constructor> <parameter class="org.jboss.modcluster.config.ha.HAModClusterConfig"> <inject bean="ModClusterConfig"/> </parameter> <parameter class="org.jboss.modcluster.load.LoadBalanceFactorProvider"> <inject bean="DynamicLoadBalanceFactorProvider"/> </parameter> <parameter class="org.jboss.ha.framework.interfaces.HAPartition"> <inject bean="HAPartition"/> </parameter> <parameter class="org.jboss.ha.framework.interfaces.HASingletonElectionPolicy"> <bean class="org.jboss.ha.singleton.HASingletonElectionPolicySimple"/> </parameter> </constructor> </bean>
25
<bean name="ModClusterConfig" class="org.jboss.modcluster.config.ha.HAModClusterConfig" mode="On Demand"> <!-- Specify configuration properties here --> </bean>
6.1.4. Connectors
Like mod_jk and mod_proxy_balancer, mod_cluster requires a connector in your server.xml to which to forward web requests. Unlike mod_jk and mod_proxy_balancer, mod_cluster is not confined to AJP, but can use HTTP as well. While AJP is generally faster, an HTTP connector can optionally be secured via SSL. If multiple possible connectors are defined in your server.xml, mod_cluster uses the following algorithm to choose between them:
1. If an native (APR) AJP connector is available, use it. 2. If an AJP connector is available, use it. 3. Otherwise, choose the HTTP connector with the highest max threads.
1. Use the value from server.xml, <Engine jvmRoute="..."/>, if defined. 2. Generate a jvm route using the configured ???. The default implementation does the following: a. Use the value of the jboss.mod_cluster.jvmRoute system property, if defined. b. Generate a UUID. While UUIDs are ideal for production systems, in a development or testing environment, it is useful to know which node served a given request just by looking at the jvm route. In this case, you can utilize the org.jboss.modcluster.SimpleJvmRouteFactory. The factory generates jvm routes of the form: bind-address:port:engine-name
26
Lifecycle Listener
Only non-clustered mode is supported Only one load metric can be used to calculate a load factor.
6.3.2. server.xml
6.3.2.1. Lifecycle listener
mod_cluster 1.0.x required you to add a lifecycle <Listener/> element to server.xml.
27
6.3.2.1.1. JBoss AS
The ModClusterListener bean now registers itself with the JBoss Web server upon deploying the mod_cluster service; and deregisters itself upon undeploy. Consequently, you no longer need to manually add a <Listener/> to server.xml.
6.3.3. mod_cluster-jboss-beans.xml
The JBoss microcontainer configuration for mod_cluster 1.0.x is *not* compatible with the configuration for 1.1.x. If you had customized your mod_cluster 1.0.x configuration, please start with the default configuration contained in the 1.1.x mod_cluster.sar and reapply any changes.
28
Chapter 7.
urn:jboss:domain:modcluster:1.0 jboss-mod-cluster.xsd
<extension module="org.jboss.as.modcluster"/>
<subsystem xmlns="urn:jboss:domain:modcluster:1.0"/>
With that configuration modcluster will listen for advertise on 224.0.1.105:23364 use the simple-load-provider with a load factor of 1.
29
Attribute factor
Property LoadBalancerFactor
Default 1
<subsystem xmlns="urn:jboss:domain:modcluster:1.0"> <mod-cluster-config advertise-socket="mod_cluster"> <dynamic-load-provider history="10" decay="2"> <load-metric type="cpu" weight="2" capacity="1"/> <load-metric type="sessions" weight="1" capacity="512"/> <custom-load-metric class="mypackage.myclass" weight="1" capacity="512"> <property name="myproperty" value="myvalue" /> <property name="otherproperty" value="othervalue" /> </custom-load-metric> </dynamic-load-provider> </mod-cluster-config> </subsystem>
30
load-metric Configuration
31
32
Chapter 8.
8.2. Building
Steps to build: 1. Download the mod_cluster sources
Note
Some unit tests require UDP port 23365. Make sure your local firewall allows the port.
33
34
Chapter 9.
host1:context1,host2:context2,host3:conte If no host is indicated, it is assumed to be the default host of the server (e.g. localhost). "ROOT" indicates the root context. Using the
35
Attribute
Default
Scope
Description default configuration, this property can by manipulated via the jboss.mod_cluster.excludedContexts system property.
autoEnableContexts
true
Configuration
If false the contexts are registered disabled in httpd, they need to be enabled via the enable() mbean method or via mod_cluster_manager. The amount of time, measure in units specified by stopContextTimeoutUnit, for which to wait for clean shutdown of a context (completion of pending requests for a distributable context; or destruction/ expiration of active sessions for a nondistributable context). The unit of time for use with stopContextTimeout
stopContextTimeout
10
Configuration
stopContextTimeoutUnitTimeUnit.SECONDS
Configuration
sessionDrainingStrategy org.jboss.modcluster.SessionDrainingStrategyEnum.DEFAULT Configuration Indicates the session draining strategy used during undeployment of a web application. There are three possible values:
36
Attribute
Default
Scope
Description if the web application is nondisributable. ALWAYS Always drain sessions before web application undeploy, even for distributable web applications. NEVER Do not drain sessions before web application undeploy, even for nondistributable web application.
proxyURL
None
Apache HTTPD
If defined, this value will be prepended to the URL of MCMP commands. Number of milliseconds to wait for a response from an httpd proxy to MCMP commands before timing out, and flagging the proxy as in error. If enabled, httpd proxies will be autodiscovered via multicast announcements. This can be used either in concert or in place of a static proxyList. UDP address on which to listen for
socketTimeout
20000
Configuration
advertise
advertiseGroupAddress 224.0.1.105
Apache HTTPD
37
Attribute
Default
Scope
advertisePort
23364
Apache HTTPD
UDP port on which to listen for httpd proxy multicast advertisements If specified, httpd proxy advertisements checksums will be verified using this value as a salt The thread factory used to create the background advertisement listener. Defines the strategy for determing the jvm route of a node, if none was specified in server.xml. The default factory first consults the
jboss.mod_cluster.jvmRoute
advertiseSecurityKey
None
Apache HTTPD
advertiseThreadFactoryExecutors.defaultThreadFactory() Configuration
jvmRouteFactory
system property. If this system property is undefined, the jvm route is assiged a UUID.
Attribute stickySession
Default true
Scope Balancer
Description Indicates whether subsequent requests for a given session should be routed to
38
Proxy Configuration
Attribute
Default
Scope
stickySessionRemove false
Balancer
Indicates whether the httpd proxy should remove session stickiness in the event that the balancer is unable to route a request to the node to which it is stuck. This property is ignored if stickySession is false. Indicates whether the httpd proxy should return an error in the event that the balancer is unable to route a request to the node to which it is stuck. This property is ignored if stickySession is false. Number of seconds to wait for a worker to become available to handle a request. When all the workers of a balancer are usable, mod_cluster will retry after a while (workerTimeout/ 100) to find an usable worker. That is timeout in the balancer mod_proxy documentation. A value of -1 indicates that the httpd will not wait for a worker to be available and will return an error if none is available.
stickySessionForce
true
Balancer
workerTimeout
-1
Balancer
39
Attribute maxAttempts
Default 1
Scope Balancer
Description Number of times an httpd proxy will attempt to send a given request to a worker before giving up. The minimum value is 1, meaning try only once. (Note that mod_proxy default is also 1: no retry).
flushPackets flushWait
false -1
Node Node
Enables/disables packet flushing Time to wait before flushing packets. A value of -1 means wait forever. Time (in seconds) in which to wait for a pong answer to a ping Soft maximum idle connection count (that is the smax in worker mod_proxy documentation). The maximum value depends on the httpd thread configuration (ThreadsPerChild or 1). Time to seconds) connections smax live (in for idle above
ping
10
Node
smax
ttl
60
Node
nodeTimeout
-1
Node
Timeout (in seconds) for proxy connections to a node. That is the time mod_cluster will wait for the back-end response before returning error. That corresponds to
40
SSL Configuration
Attribute
Default
Scope
Description timeout in the worker mod_proxy documentation. A value of -1 indicates no timeout. Note that mod_cluster always uses a cping/cpong before forwarding a request and the connectiontimeout value used by mod_cluster is the ping value.
balancer loadBalancingGroup
mycluster None
Node Node
The balancer name If specified, load will be balanced among jvmRoutes withing the same load balancing group. A loadBalancingGroup is conceptually equivalent to a mod_jk domain directive. This is primarily used in conjunction with partitioned session replication (e.g. buddy replication).
Note
When nodeTimeout is not defined the ProxyTimeout directive Proxy is used. If ProxyTimeout is not defined the server timeout (Timeout) is used (default 300 seconds). nodeTimeout, ProxyTimeout or Timeout is set at the socket level.
41
Note
This HTTP/HTTPS channel should not be confused with the processing of HTTP/ HTTPS client requests.
Default false
The default JSSE cipher suites Overrides the cipher suites used to init an SSL socket ignoring any unsupported ciphers TLS Overrides the default SSL socket protocol. key The algorithm of the key manager factory containing client certificates The password granting access to the key store The type of key store
sslProtocol
sslCertificateEncodingAlgorithmThe default JSSE manager algorithm sslKeyStore sslKeyStorePassword sslKeyStoreType sslKeyStoreProvider sslTrustAlgorithm sslKeyAlias
changeit JKS
The default JSSE security The key store provider provider The default JSSE manager algorithm trust The algorithm of the trust manager factory The alias of the key holding the client certificates in the key store Certificate revocation list 5 The maximum length of a certificate held in the trust store containing the trust store
sslCrlFile sslTrustMaxCertLength
42
HA Configuration
9.4. HA Configuration
Additional configuration properties when mod_cluster is configured in clustered mode. Attribute Default Description If the loadBalancingGroup directive is used, should HA partition use a singleton master loadBalancingGroup. per
masterPerLoadBalancingGroup false
org.jboss.modcluster.load.metric.impl.BusyConnectorsLoadMetric Class name of an object implementing org.jboss.load.metric.LoadMetric 1 The capacity of the load metric defined via the loadMetricClass property The number of historic load values to consider in the load balance factor computation. The factor by which a historic load values should degrade in significance.
loadMetricCapacity
loadHistory
loadDecayFactor
43
44
Chapter 10.
ceFactorProviderMBean.class)</ annotation> <constructor> <parameter> <set elementClass="org.jboss.modcluster.load.metric.LoadMetric"> <inject bean="BusyConnectorsLoadMetric"/> <inject bean="HeapMemoryUsageLoadMetric"/> </set> </parameter> </constructor> <property name="history">9</property> <property name="decayFactor">2</property> </bean>
Load metrics can be configured with an associated weight and capacity. The weight (default is 1) indicates the significance of a metric with respect to the other metrics. For example, a metric of weight 2 will have twice the impact on the overall load factor than a metric of weight 1. The capacity of a metric serves 2 functions: To normalize the load values from each metric. In some load metrics, capacity is already reflected in the load values. The capacity of a metric should be configured such that 0 <= (load / capacity) >= 1. To favor some nodes over others. By setting the metric capacities to different values on each node, proxies will effectively favor nodes with higher capacities, since they will return smaller load values. This adds an interesting level of granularity to node weighting. Consider a cluster of two nodes, one with more memory, and a second with a faster CPU; and two metrics, one memory-based and the other CPU-based. In the memory-based metric, the first node would be given a higher load capacity than the second node. In a CPU-based metric, the second node would be given a higher load capacity than the first node.
45
Each load metric contributes a value to the overall load factor of a node. The load factors from each metric are aggregated according to their weights. In general, the load factor contribution of given metric is: (load / capacity) * weight / total weight. The DynamicLoadBalanceFactorProvider applies a time decay function to the loads returned by each metric. The aggregate load, with respect to previous load values, can be expressed by the following formula: L = (L0 + L1/D + L2/D + L3/D + ... + LH/D ) * (1 + D + D + D + ... D ) ... or more concisely as: L = (#
H i=0 2 3 H 2 3 H
Li/D ) * (#
H i=0
D)
... where D = decayFactor, and H = history. Setting history = 0 effectively disables the time decay function and only the current load for each metric will be considered in the load balance factor computation. The mod_cluster load balancer expects the load factor to be an integer between 0 and 100, where 0 indicates max load and 100 indicates zero load. Therefore, the final load factor sent to the load balancer LFinal = 100 - (L * 100) While you are free to write your own load metrics, the following LoadMetrics are available out of the box:
46
BusyConnectorsLoadMetric
</constructor> <property name="capacity">1000</property> </bean> <bean name="SessionLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.SessionLoadMetricSource" <constructor> <parameter class="javax.management.MBeanServer"> <inject bean="JMXKernel" property="mbeanServer"/> </parameter> </constructor> </bean>
10.1.2. BusyConnectorsLoadMetric
Returns the percentage of connector threads from the thread pool that are busy servicing requests Uses ThreadPoolLoadMetricSource to query connector thread Analogous to method=B in mod_jk e.g.
.class)</
annotation> <constructor> <parameter><inject bean="ThreadPoolLoadMetricSource"/></parameter> </constructor> </bean> <bean name="ThreadPoolLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.ThreadPoolLoadMetricS <constructor> <parameter class="javax.management.MBeanServer"> <inject bean="JMXKernel" property="mbeanServer"/> </parameter> </constructor> </bean>
10.1.3. ReceiveTrafficLoadMetric
Returns the incoming request POST traffic in KB/sec (the application needs to read POST data) Requires an explicit capacity
47
<parameter class="org.jboss.modcluster.load.metric.impl.RequestProcessorLoadMetricSource"> <inject bean="RequestProcessorLoadMetricSource"/> </parameter> </constructor> <property name="capacity">1024</property> </bean> <bean name="RequestProcessorLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.RequestProcesso <constructor> <parameter class="javax.management.MBeanServer"> <inject bean="JMXKernel" property="mbeanServer"/> </parameter> </constructor> </bean>
10.1.4. SendTrafficLoadMetric
Returns the outgoing request traffic in KB/sec Requires an explicit capacity Uses RequestProcessorLoadMetricSource to query request processors Analogous to method=T in mod_jk
48
RequestCountLoadMetric
10.1.5. RequestCountLoadMetric
Returns the number of requests/sec Requires an explicit capacity Uses RequestProcessorLoadMetricSource to query request processors Analogous to method=R in mod_jk e.g.
ass)</ annotation> <constructor> <parameter class="org.jboss.modcluster.load.metric.impl.RequestProcessorLoadMetricSource"> <inject bean="RequestProcessorLoadMetricSource"/> </parameter> </constructor> <property name="capacity">1000</property> </bean>
49
class)</
annotation> <constructor> <parameter><inject bean="OperatingSystemLoadMetricSource"/></parameter> </constructor> </bean> <bean name="OperatingSystemLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.OperatingSystemL </bean>
10.2.2. SystemMemoryUsageLoadMetric
Returns system memory usage Requires com.sun.management.OperatingSystemMXBean (available in Sun's JDK or OpenJDK) Uses OperatingSystemLoadMetricSource to generically read attributes e.g.
10.2.3. HeapMemoryUsageLoadMetric
Returns the heap memory usage as a percentage of max heap size e.g.
50
Other metrics
MBean.class)</
annotation> <constructor> <parameter><inject bean="ConnectionPoolLoadMetricSource"/></parameter> </constructor> </bean> <bean name="ConnectionPoolLoadMetricSource" class="org.jboss.modcluster.load.metric.impl.ConnectionPoolLoa <constructor> <parameter class="javax.management.MBeanServer"> <inject bean="JMXKernel" property="mbeanServer"/> </parameter> </constructor> </bean>
51
52
Chapter 11.
cp -r /tmp/mod_cluster/mod_cluster.sar $JBOSS_HOME/server/all/deploy
cp -r /tmp/mod_cluster/JBossWeb-Tomcat/lib/* $CATALINA_HOME/lib/
53
54
Chapter 12.
Listen 6666 <VirtualHost 10.33.144.3:6666> SSLEngine on SSLCipherSuite AES128-SHA:ALL:!ADH:!LOW:!MD5:!SSLV2:!NULL SSLCertificateFile conf/server.crt SSLCertificateKeyFile conf/server.key SSLCACertificateFile conf/server-ca.crt SSLVerifyClient require SSLVerifyDepth 10 </VirtualHost>
The conf/server.crt file is the PEM-encoded Certificate file for the VirtualHost it must be signed by a Certificate Authority (CA) whose certificate is stored in the sslTrustStore of the ClusterListener parameter. The conf/server.key file is the file containing the private key. The conf/server-ca.crt file is the file containing the certicate of the CA that have signed the client certificate JBossWEB is using. That is the CA that have signed the certificate corresponding to the sslKeyAlias stored in the sslKeyStore of the ClusterListener parameters.
<Listener className="org.jboss.web.cluster.ClusterListener"
55
The sslKeyStore file contains the private key and the signed certificate of the client certificate JBossWEB uses to connect to httpd. The certificate must be signed by a Cerficate Authority (CA) who certificate is in the conf/server-ca.crt file of the httpd The sslTrustStore file contains the CA certificate of the CA that signed the certificate contained in conf/server.crt file.
<property name="ssl">true</property> <property name="sslKeyStorePass">changeit</property> <property name="sslKeyStore">/home/jfclere/CERTS/test.p12</property> <property name="sslKeyStoreType">pkcs12</property> <property name="sslTrustStore">/home/jfclere/CERTS/ca.p12</property> <property name="sslTrustStoreType">pkcs12</property> <property name="sslTrustStorePassword">changeit</property>
56
/etc/pki/tls/misc/CA -newca
That creates a directory for example ../../CA that contains a cacert.pem file which content have to be added to the conf/server-ca.crt described above.
/etc/pki/tls/misc/CA -newreq
That creates 2 files named newreq.pem and newkey.pem. newkey.pem is the file conf/ server.key described above. 2. Sign the request:
/etc/pki/tls/misc/CA -signreq
That creates a file named newcert.pem. newcert.pem is the file conf/server.crt described above. At that point you have created the SSL stuff needed for the VirtualHost in httpd. You should use a browser to test it after importing in the browser the content of the cacert.pem file.
/etc/pki/tls/misc/CA -newreq
That creates 2 files: Request is in newreq.pem, private key is in newkey.pem 3. Sign the request.
57
/etc/pki/tls/misc/CA -signreq
That creates a file: newcert.pem 4. Don't use a passphrase when creating the client certicate or remove it before exporting:
conf/proxy.pem should contain both key and certificate. The certificate must be trusted by Tomcat via the CA in truststoreFile of <connector/>. conf/cacert.pem must contain the certificat of the CA that signed the AS/TC certificate. The correspond key and certificate are the pair specificed by keyAlias and truststoreFile of the <connector/>. Of course the <connector/> must be the https one (normally on port 8443).
58
make sure you use the keystore password as Export passphrase. 2. Import the contents of the p12 file in the keystore:
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" keyAlias="1" truststoreFile="/etc/pki/java/cacerts" maxThreads="150" scheme="https" secure="true" clientAuth="true" sslProtocol="TLS" />
59
openssl s_client -CAfile /home/jfclere/CA/cacert.pem -cert newcert.pem -key newkey.pem \ -host localhost -port 8443
There shouldn't be any error and you should be able to see your CA in the "Acceptable client certificate CA names".
12.3. Forwarding SSL browser informations when using http/https between httpd and JBossWEB
When using http or https beween httpd and JBossWEB you need to use the SSLValve and export the SSL variable as header in the request in httpd. If you are using AJP, mod_proxy_ajp will read the SSL variables and forward them to JBossWEB automaticaly. (See Forwarding SSL environment when using http/https proxy [http://www.jboss.org/community/ docs/DOC-11988] for detailed instructions). The SSL variable used by mod_proxy_ajp are the following:
1. "HTTPS" SSL indicateur. 2. "SSL_CLIENT_CERT" Chain of client certificates. 3. "SSL_CIPHER" Cipher used. 4. "SSL_SESSION_ID" Id of the session. 5. "SSL_CIPHER_USEKEYSIZE" Size of the key used.
60
Chapter 13.
nodeTimeout -
connection_pool_minsize connection_pool_timeout
smax ttl
retries recovery_options
workerTimeout maxAttempts -
61
Remarks Not supported Not supported in this version. Use ProxyIOBufferSize Not supported The ClusterListener will tell (via a STATUS message) mod_cluster that the node is up again mod_cluster receives this information via ENABLE/ DISABLE/STOP messages mod_cluster handles this via the loadfactor logic The context "mounted" automaticly via the ENABLEAPP messages. ProxyPass could be used too
activation
distance mount
secret connect_timeout
Not supported Not supported. ProxyTimeout or TimeOut (Default seconds) Default 10 seconds Not supported. Use ProxyTimeout or server TimeOut? directive (Default 300 seconds) Use server 300
prepost_timeout reply_timeout
ping -
62
Chapter 14.
ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass /foo http://foo.example.com/bar ProxyPassReverse /foo http://foo.example.com/bar
All the general proxy parameters could be used in mod_cluster they work like in mod_proxy, only the balancers and the workers definitions are slightly different.
14.1. Workers
Mod_proxy Parameter min max smax ttl acquire disablereuse ClusterListener parameter smax ttl workerTimeout Remarks Not supported in this version mod_cluster uses mod_proxy default value Same as mod_proxy Same as mod_proxy Same as mod_proxy acquire but in seconds mod_cluster will disable the node in case of error and the ClusterListener will for the reuse via the STATUS message Same as mod_proxy Same as mod_proxy Always on: OS KEEP_ALIVE is always used. Use connectionTimeout in the <Connector> if needed Not supported
flushPackets flushwait -
lbset
63
Remarks Same as mod_proxy Default value 10 seconds The load factor is received by mod_cluster from a calculated value in the ClusterListener Not supported lbfactor sent to 0 makes a standby node ClusterListener will test when the node is back online In fact JBossWEB via the JVMRoute in the Engine will add it mod_cluster has a finer status handling: by context via the ENABLE/STOP/DISABLE/ REMOVE application messages. hot-standby is done by lbfactor = 0 and Error by lbfactor = 1 both values are sent in STATUS message by the ClusterListener Default wait for ever (http:// httpd.apache.org/docs/2.2/ mod/mod_proxy.html is wrong there) Default 60 seconds
JVMRoute
status
timeout
nodeTimeout
ttl
ttl
14.2. Balancers
Mod_proxy Parameter lbmethod ClusterListener parameter Remarks There is only one load balancing method in mod_cluster "cluster_byrequests" Default 3 Same as in mod_proxy The 2 parameters in the ClusterListener are combined in one that behaves like in mod_proxy
64
Balancers
65
66
Chapter 15.
The demo's "Datasource Use" load generation scenario requires the use of JBoss Application Server.
67
5. Deploy the load-demo.war found in the distribution's demo/server folder to your JBossAS/ JBossWeb/Tomcat servers. 6. Start the demo application: a. On *nix:
cd ~/mod_cluster/demo/client ./run-demo.sh
b. On Windows:
68
7. Configure the hostname and address of the httpd server, the number of client threads, etc and click the "Start" button. See Client Driver Configuration Options for details on the configuration options. 8. Switch to the "Request Balancing" tab to see how many requests are going to each of your JBossAS/JBossWeb/Tomcat servers. 9. Switch to the "Session Balancing" tab to see how many active sessions by each of your JBossAS/JBossWeb/Tomcat servers.
2
10.Stop some of your JBossAS/JBossWeb/Tomcat servers and/or undeploy the load-demo.war from some of the servers and see the effect this has on load balancing. 11.Restart some of your JBossAS/JBossWeb/Tomcat servers and/or re-deploy the load-demo.war to some of the servers and see the effect this has on load balancing. 12.Experiment with adding artificial load to one or more servers to see what effect that has on load balancing. See Load Generation Scenarios for details. Most of the various panels in application interface also present information on the current status on any client threads. "Total Clients" is the number of client threads created since the last time the "Start" button was pushed. "Live Clients" is the number of threads currently running. "Failed Clients" is the number of clients that terminated abnormally; i.e. made a request that resulted in something other than an HTTP 200 response.
69
The panel includes the following options: 1. Proxy Hostname: Hostname of the load balancer or the IP address on which it is listening for requests
3
2. Proxy Port: Port on which the load balancer is listening for requests 4 3. Context Path: Portion of the request URL that specifies the request is for the load-demo.war 4. Session Life: Number of seconds a client thread should use a session before invalidating or abandoning it. Generally it is good to keep this to a small value; otherwise the use of session stickiness will prevent changes in server load from affecting the load balancer's routing decisions. With sticky sessions enabled (strongly recommended), it is the creation of a new session that allows the load balancer to try to balance load. 5. Invalidate: Controls what the client thread should do when it stops using a session because Session Life has passed. If checked, the driver will send a request that results in the session
70
being invalidated. If unchecked, the session will just be abandoned, and will continue to exist on the server until Session Timeout seconds have passed. In the future this will likely be changed to a percentage input, so X% can be invalidated, the rest abandoned. 6. Session Timeout: Number of seconds a session can remain unused before the server is free to expire it. Unchecking Invalidate and setting a high value relative to Session Life allows a significant number of unused sessions to accumulate on the server. 7. Num Threads: Number of client threads to launch. Each thread repeatedly makes requests until the "Stop" button is pushed or a request receives a response other than HTTP 200. 8. Sleep Time: Number of ms the client threads should sleep between requests. 9. Startup Time: Number of seconds over which the application should stagger the start of the client threads. Staggering the start advised as it avoids the unnatural situation where for the life of the demonstation all sessions start at about the same time and then are invalidated or abandoned at the same time. Staggering the start allows the load balancer to continually see new sessions and decide how to route them.
71
Target Hostname and Target Port: The hostname or IP address of the server on which you want load generated. There are two strategies for setting these: 1. You can use the hostname and port of the load balancer, in which case the load balancer will pick a backend server and route the request to it. Note the client application does not maintain a session cookie for these requests, so if you invoke another server load generation request, you shouldn't expect the same server to handle it. 2. If the JBoss AS/JBossWeb/Tomcat servers are running the HttpConnector as well as the AJP connector, you can specify the address and port on which a particular server's HttpConnector is listening. The standard port is 8080. Load Creation Action: Specifies the type of load the target server should generate. See below for details on the available load types.
72
Params: Zero or more parameters to pass to the specified load creation servlet. For example, in the screenshot above, Number of Connections and Duration. How many parameters are displayed, their name and their meaning depend on the selected Load Creation Action. The label for each parameter includes a tooltip that explains its use. The available Load Creation Actions are as follows: Active Sessions Generates server load by causing session creation on the target server. Datasource Use Generates server load by taking connections from the java:DefaultDS datasource for a period Connection Pool Use Generates server load by tieing up threads in the webserver connections pool for a period Heap Memory Pool Use Generates server load by filling 50% of free heap memory for a period CPU Use Generates server CPU load by initiating a tight loop in a thread Server Receive Traffic Generates server traffic receipt load by POSTing a large byte array to the server once per second for a period Server Send Traffic Generates server traffic send load by making a request once per second to which the server responds with a large byte array Request Count Generates server load by making numerous requests, increasing the request count on the target server
73
74
Chapter 16.
Change Log
16.1. 1.1.3.Final (12 August 2011)
request hang with a node is stopped in EC2 (MODCLUSTER-217) (jfclere) Extra ENABLE-APP/REMOVE-APP event after failover (MODCLUSTER-220) (jfclere) mod_cluster does not work with Tomcat 7 due to API Change in Connector (MODCLUSTER240) (jfclere) kill -HUP httpd process increase the number of open locks (MODCLUSTER-241) (jfclere)
Second attempt to connect from Jboss to apache module sends incomplete Host Header (MODCLUSTER-216) (jfclere) when using tomcat manager webapp to stop/ start an application the start is ignored by mod_cluster (MODCLUSTER-224) (jfclere) Unable to override load properties when running in Tomcat 6 (MODCLUSTER-232) (jfclere) Documentation contains wrong default loadMetric class name (MODCLUSTER-233) (jfclere)
75
mod_cluster should issue a warning when Maxcontext is reached and no more context will be taken (MODCLUSTER-223) (jfclere) add a note explaining where Maxcontext must be put in httpd.conf and issue error if in wrong location (MODCLUSTER-225) (jfclere)
76
mod_advertise: Invalid ServerAdvertise Address too often (MODCLUSTER-172) (jfclere) Fix class name of MBeanAttributeRatioLoadMetric in MC config (MODCLUSTER-174) (pferraro) Wrong configuration could cause an httpd core (MODCLUSTER-175) (jfclere) Advertise not configured error message in log is actually a warning (MODCLUSTER-176) (jfclere) Better no servers connected (MODCLUSTER-165) (jfclere) message
How does the UI deal with 20 or more servers (MODCLUSTER-165) (jfclere) mod_cluster should use hostname provided in address instead a IP address (MODCLUSTER168) (pferraro) Read only view of mod_cluster-manager (MODCLUSTER-181) (jfclere) Demo client throws Bus Error when run with JDK 1.6 on OSX (MODCLUSTER-169) (jfclere) Use versioned docs (MODCLUSTER-141) (jfclere, pferraro) Deprecate use of term "domain" (MODCLUSTER-177) (jfclere, pferraro)
77
Quotes in jsessionId causing sticky sessions to fail (MODCLUSTER-146) (jfclere) ManagerBalancerName doesn't (MODCLUSTER-153) (jfclere) work
Parsing of IPv6 loopback address fails (MODCLUSTER-156) (pferraro) SystemMemoryUsageLoadMetric wrong load (pferraro) metric returns (MODCLUSTER-157)
Clean shutdown logic can still inadvertently kill requests for non-distributed contexts. (MODCLUSTER-159) (pferraro) NoClassDefFoundError running demo app against AS6 (MODCLUSTER-161) (pferraro) Allow override of default clean shutdown behavior (MODCLUSTER-139) (pferraro) Avoid unnecessary open sockets for nonmaster nodes (MODCLUSTER-158) (pferraro)
improve packaging so that the bundle can run in ~ too (MODCLUSTER-150) (jfclere) jboss.mod_cluster.proxyList: invalid hosts cause mod-cluster startup to be delayed (MODCLUSTER-155) (pferraro) mod_cluster 1.1.0.CR1 doesn't work with Tomcat (MODCLUSTER-143) (jfclere/ pferraro) Allow configuration of stopContextTimeout units (MODCLUSTER-138) (pferraro) Add a solaris10 64 bits sparc in the bundles (MODCLUSTER-137) (jfclere) INFO and mod_cluster_manager/ displays milliseconds and DUMP second (MODCLUSTER-128) (jfclere)
78
Make mod_cluster manager tolerant to F5 page refresh when disabled context (MODCLUSTER-124) (jfclere)
Mod_cluster does support more that 3 Alias in <Host/> (MODCLUSTER-121) (jfclere) Allow toggling of context auto-enable during mod_cluster startup. (MODCLUSTER-125) (pferraro) STATUS should retry the worker even if there was an error before. (MODCLUSTER-133) (jfclere) Split ModClusterServiceMBean.ping(String) into 3 methods (MODCLUSTER-110) (pferraro/jfclere) Use clean shutdown by default, leveraging STOP-APP-RSP for <distributable/> contexts and session draining for non-distributable contexts. mod_cluster shutdown now triggered earlier via Connector JMX notification. (MODCLUSTER-131) (pferraro/jfclere)
79
move the web site to (MODCLUSTER-114) (.org team) ping and nodeTimeout (MODCLUSTER-132) (jfclere) update mod_jk to 1.2.30 138) (jfclere) 118) (jfclere)
magnolia interact.
(MODCLUSTER-
query string is truncated to (MODCLUSTERAdvertiseBindAddress does not default to the 23364 port (MODCLUSTER-119) (jfclere) Skip load balance factor calculation if there are no proxies to receive status message (MODCLUSTER-103) (pferraro) Disabling contexts does (MODCLUSTER-123) (jfclere) not work
advertise doesn't use new AdvertiseSecurityKey on graceful restarts. (MODCLUSTER-129) (jfclere) Load-demo.war specifies obsolete servlet in web.xml (MODCLUSTER-113) (pferraro)
80
version.
getProxyInfo failed when there are too many nodes. (MODCLUSTER-94) (jfclere) mod_cluster-manager display corrupted with jboss starting. (MODCLUSTER-95) (jfclere) DISABLE application active as STOPPED. (MODCLUSTER-96) (jfclere) Httpd should remove workers it can't ping. (MODCLUSTER-97) (jfclere) Linux mod_cluster_manager display zero instead values. (MODCLUSTER-98) (jfclere) mod_cluster_manager doesn't seem to ENABLE/DISABLE the right context. (MODCLUSTER-99) (jfclere) load balancing logic doesn't allow manual demo of load-balancing. (MODCLUSTER-100) (jfclere) 404 errors when load is (MODCLUSTER-102) (jfclere) increasing.
Advertise security key verification does not work. (MODCLUSTER-104) (jfclere) Allow advertise listener to listen on a specific network interface. (MODCLUSTER106) (pferraro) Allow thread factory injection for advertise listener. (MODCLUSTER-108) (pferraro) Create SPI and isolate tomcat/jbossweb usage into service provider implementation. (MODCLUSTER-111) (pferraro)
81
82
Chapter 17.
HTTP/1.0 200 OK Date: Wed, 08 Apr 2009 12:26:32 GMT Sequence: 16 Digest: f2d5f806a53effa6c67973d2ddcdd233 Server: 1b60092e-76f3-49fd-9f99-a51c69c89e2d X-Manager-Address: 127.0.0.1:6666 X-Manager-Url: /bla X-Manager-Protocol: http X-Manager-Host: 10.33.144.3
The X-Manager-Address header value is used by the cluster logic to send information about the cluster to the proxy. It is the IP and port of the VirtualHost where mod_advertise is configured or URL parameter of the ServerAdvertise directive. See Proxy Discovery in Configuration Properties and mod_advertise in Apache httpd configuration.
ServerAdvertise Off
In mod_cluster-jboss-beans.xml add the addresses and ports of the VirtualHost to the proxyList property and set advertise to false, for example:
83
17.4.1. No error
That happens when Advertise is not working: The nodes don't get the advertise messages from httpd.
1. Check the modules are loaded and Advertise is started. In httpd.conf activate extended information display, add:
AllowDisplay On
84
No error
If not, go to the Minimal Example and add the missing directive(s). 2. Check that Advertise message are received on the cluster node. A small Java [http:// anonsvn.jboss.org/repos/mod_cluster/trunk/test/java/Advertize.java] utility could be used to check Advertise. It is in the mod_cluster repository and can be compiled using javac. A compiled version can be found under in /opt/jboss/httpd/tools in the bundles. Run it using java Advertise multicastaddress port. The output should be something like:
[jfclere@jfcpc java]$ java Advertize 224.0.1.105 23364 ready waiting... received: HTTP/1.0 200 OK Date: Mon, 28 Jun 2010 07:30:31 GMT Sequence: 1 Digest: df8a4321fa99e5098174634f2fe2f87c
85
Server: 1403c3be-837a-4e76-85b1-9dfe5ddb4378 X-Manager-Address: test.example.com:6666 X-Manager-Url: /1403c3be-837a-4e76-85b1-9dfe5ddb4378 X-Manager-Protocol: http X-Manager-Host: test.example.com
3. No Advertise messages Check firewall (don't forget the boxes firewall). Advertise uses UDP port 23364 and multicast addresse 224.0.1.105 4. Can't get Advertise messages Use ProxyList property. In case Advertise can't work you put the address and port of the VirtualHost used in httpd to receive the MCMP. In server/profile/deploy/mod_cluster.sar/METAINF/mod_cluster-jboss-beans.xml
<property name="proxyList">test.example.com:6666</property>
or in server.xml:
18:36:14,533 INFO [DefaultMCMPHandler] IO error sending command INFO to proxy jfcpc/ 10.33.144.3:8888
You can use telnet hostname/address port to check by hands that it is OK for example:
[jfclere@jfcpc docs]$ telnet 10.33.144.3 8888 Trying 10.33.144.3... Connected to jfcpc. Escape character is '^]'. GET /
86
Check that the address and port are the expected ones you may use ServerAdvertise On http:/ /hostname:port, like:
ServerAdvertise On http://localhost:6666
Or use the servlet testhttpd in the testhttpd.war of the bundle (in /opt/jboss/httpd/tools). Install/ deploy it in in the node and start the AS/Tomcat on the node, than access to the node directly and call /testhttpd/testhttpd
If you don't get a similar page the output should help to find that is wrong.
87
Mon Jun 28 18:08:47 2010] [error] [client 10.33.144.3] client denied by server configuration: /
<Directory /> Order deny,allow Deny from all Allow from 10.33.144.3 </Directory>
88