이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 3. Load balancing with the JBoss HTTP connector (mod_cluster)
The mod_cluster connector is a reduced configuration, intelligent load-balancing solution for JBoss EAP and JBoss Web Server Tomcat. The mod_cluster module is based on technology originally developed by the JBoss mod_cluster community project.
3.1. JBoss HTTP connector (mod_cluster) 링크 복사링크가 클립보드에 복사되었습니다!
The mod_cluster module load-balances HTTP requests to JBoss EAP and JBoss Web Server Tomcat worker nodes. The mod_cluster module uses the Apache HTTP Server as the proxy server.
Key features of mod_cluster
The mod_cluster connector has several advantages over the mod_jk connector:
-
When the
mod_clustermodule is enabled, themod_clusterManagement Protocol (MCMP) is an additional connection between the Tomcat servers and the Apache HTTP Server. The Tomcat servers use MCMP to transmit server-side load figures and lifecycle events back to the Apache HTTP Server, by using a custom set of HTTP methods. -
Dynamic configuration of Apache HTTP Server with
mod_clusterallows Tomcat servers that havemod_clusterlisteners to join the load-balancing arrangement without the need for manual configuration. - Tomcat servers perform the load calculations rather than rely on the Apache HTTP Server. This makes load-balancing metrics more accurate than other connectors.
-
The
mod_clusterconnector provides fine-grained application lifecycle control. Each Tomcat server forwards web application context lifecycle events to the Apache HTTP Server. These lifecycle events include informing the Apache HTTP Server to start or stop routing requests for a specific context. This prevents end users from seeing HTTP errors because of unavailable resources. -
You can use Apache JServ Protocol (AJP), Hypertext Transfer Protocol (HTTP), or Hypertext Transfer Protocol Secure (HTTPS) transports with
mod_cluster.
Mod_cluster components
On the proxy server, mod_cluster consists of four Apache modules:
| Component | Description |
|---|---|
|
| The Shared Memory Manager module shares real-time worker node information with multiple Apache HTTP Server processes. |
|
| The Cluster Manager module receives and acknowledges messages from worker nodes, including node registrations, node load data, and node application life-cycle events. |
|
| The Proxy Balancer Module handles request routing to cluster nodes. The Proxy Balancer selects the appropriate destination node based on application location in the cluster, the current state of each of the cluster nodes, and the Session ID (if a request is part of an established session). |
|
| The Proxy Advertisement Module broadcasts the existence of the proxy server via UDP multicast messages. The server advertisement messages contain the IP address and port number where the proxy server is listening for responses from worker nodes that want to join the load-balancing cluster. |
3.2. Mod_cluster character limits 링크 복사링크가 클립보드에 복사되었습니다!
The mod_cluster module uses shared memory to keep the nodes description. The shared memory is created at the startup of Apache HTTP Server, and the structure of each item is fixed.
When you define proxy server and worker node properties, ensure that you adhere to the following character limits:
| Property | Maximum character limit | Description |
|---|---|---|
| Alias length | 100 characters |
Alias corresponds to the network name of the respective virtual host; the name is defined in the |
| Context length | 40 characters |
For example, if |
| Balancer name length | 40 characters |
This is the balancer property in |
|
| 80 characters |
|
| Domain name length | 20 characters |
This is the domain property in |
| Hostname length for a node | 64 characters |
This is hostname address in the |
| Port length for a node | 7 characters |
This is the port property in the |
| Scheme length for a node | 6 characters |
This is the protocol of the connector. Possible values are |
| Cookie name length | 30 characters |
This is the header cookie name for the session ID. The default value is |
| Path name length | 30 characters |
This is the parameter name for the session ID. The default value is |
| Session ID length | 120 characters |
A session ID is in the following type of format: |
3.3. Mod_cluster installation 링크 복사링크가 클립보드에 복사되었습니다!
The mod_cluster module is included in the Apache HTTP Server part of a JBoss Core Services installation.
You can follow the procedures in the Red Hat JBoss Core Services Apache HTTP Server Installation Guide to download and install the Apache HTTP Server for your operating system.
3.4. Apache HTTP Server load-balancing configuration when using mod_cluster 링크 복사링크가 클립보드에 복사되었습니다!
In JBoss Web Server 2.1 and higher, mod_cluster is configured correctly for Apache HTTP Server by default. For more information about setting a custom configuration, see Configuring a basic proxy server.
You can also use the Load Balancer Configuration tool on the Red Hat Customer Portal to generate optimal configuration templates quickly for mod_cluster and Tomcat worker nodes.
When you use the Load Balancer Configuration tool for JBoss Web Server 5.6, ensure that you select 2.4.x as the Apache version, and select Tomcat as the back-end configuration.
3.5. Configuring a basic proxy server 링크 복사링크가 클립보드에 복사되었습니다!
You can configure the Apache HTTP Server to function as a proxy server that forwards requests and responses between web clients and back-end web servers. You must configure a proxy server listener to receive connection requests and responses from the back-end worker nodes. When you want to configure a load-balancing proxy server that uses mod_cluster, you must also configure a virtual host for the management channel.
Prerequisites
-
You have installed the Apache HTTP Server and configured the
mod_clustermodules for your installation. For more information, see the Red Hat JBoss Core Services Apache HTTP Server Installation Guide. - The port that you specify for the proxy server listener must be open for incoming TCP connections.
Procedure
Open the
mod_clusterconfiguration file.NoteThe
mod_clusterconfiguration file is typically located in theJBCS_HOME/httpd/conf.d/mod_cluster.confdirectory.To create a
Listendirective for the proxy server, enter the following line in themod_cluster.conffile:Listen IP_ADDRESS:PORT_NUMBER
Listen IP_ADDRESS:PORT_NUMBERCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIn the preceding example, replace
IP_ADDRESSwith the address of the server network interface that the proxy server uses to communicate with the worker nodes, and replacePORT_NUMBERwith the port that the proxy server listens on.Ensure that the port is open for incoming TCP connections.
To create a virtual host, enter the following details in the
mod_cluster.conffile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIn the preceding example, replace
IP_ADDRESSandPORT_NUMBERwith the address of the server network interface and port number that you have specified for theListendirective.This address and port combination is only used for
mod_clustermanagement messages. This address and port combination is not used for general traffic.
For more information about configuring mod_jk and starting the Apache HTTP Server service, see the Red Hat JBoss Core Services Apache HTTP Server Installation Guide.
3.5.1. Disabling server advertisement 링크 복사링크가 클립보드에 복사되었습니다!
The proxy server uses UDP multicast to advertise itself. The AdvertiseFrequency directive instructs the server to send server advertisement messages every 10 seconds by default. Server advertisement messages contain the IP_ADDRESS and PORT_NUMBER that you specify in the VirtualHost definition. Worker nodes that are configured to respond to server advertisements use this information to register themselves with the proxy server. If you want to prevent worker nodes from registering with the proxy server, you can optionally disable server advertisement.
When UDP multicast is available between the proxy server and the worker nodes, server advertisement adds worker nodes without requiring further configuration on the proxy server. Server advertisement requires only minimal configuration on the worker nodes.
Prerequisites
- You have configured a basic proxy server.
Procedure
Open the
mod_clusterconfiguration file.NoteThe
mod_clusterconfiguration file is typically located in theJBCS_HOME/httpd/conf.d/mod_cluster.confdirectory.Add the following directive to the
VirtualHostdefinition:ServerAdvertise Off
ServerAdvertise OffCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf server advertisements are disabled, or UDP multicast is not available on the network between the proxy server and the worker nodes, you can configure worker nodes with a static list of proxy servers. In either case, you do not need to configure the proxy server with a list of worker nodes.
3.5.2. Logging worker node details 링크 복사링크가 클립보드에 복사되었습니다!
When you configure a load-balancing proxy server that uses mod_cluster, you can optionally configure the Apache HTTP Server to log details of each worker node that handles a request. Logging worker node details can be useful if you need to troubleshoot your load balancer.
Prerequisites
- You have configured a basic proxy server.
Procedure
Open the
mod_clusterconfiguration file.NoteThe
mod_clusterconfiguration file is typically located in theJBCS_HOME/httpd/conf.d/mod_cluster.confdirectory.Add the following details to your Apache HTTP Server
LogFormatdirective(s):%{BALANCER_NAME}e :: The name of the balancer that served the request. %{BALANCER_WORKER_NAME}e :: The name of the worker node that served the request.%{BALANCER_NAME}e :: The name of the balancer that served the request. %{BALANCER_WORKER_NAME}e :: The name of the worker node that served the request.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.6. Configuring a Tomcat worker node in mod_cluster 링크 복사링크가 클립보드에 복사되었습니다!
When you use mod_cluster, you can configure a Tomcat worker node as a JBoss Web Server Tomcat service that operates in non-clustered mode only. In this situation, only one load metric can be used at a time when calculating the load balance factor.
JBoss Web Server Tomcat worker nodes support only a subset of mod_cluster functionality. Full mod_cluster functionality is available with JBoss EAP.
Prerequisites
- You have installed a supported instance of JBoss Web Server.
-
You are familiar with the
mod_clusterproxy and proxy discovery configuration parameters.
Procedure
To add a listener to Tomcat, add the following
Listenerelement below the otherListenerelements in theJWS_HOME/tomcat<VERSION>/conf/server.xmlfile:<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="true" stickySession="true" stickySessionForce="false" stickySessionRemove="true" />
<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="true" stickySession="true" stickySessionForce="false" stickySessionRemove="true" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow To give the worker node a unique identity, edit the
JWS_HOME/tomcat<VERSION>/conf/server.xmlfile, to add thejvmRouteattribute and value to theEngineelement:<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker01">
<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker01">Copy to Clipboard Copied! Toggle word wrap Toggle overflow To configure
STATUS MCMPmessage frequency, modify theorg.jboss.modcluster.container.catalina.status-frequencyJava system property.For example:
-Dorg.jboss.modcluster.container.catalina.status-frequency=6
-Dorg.jboss.modcluster.container.catalina.status-frequency=6Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteTomcat worker nodes periodically send status messages that contain their current load status to the Apache HTTP Server balancer. The default frequency of these messages is 10 seconds. If you have hundreds of worker nodes, the
STATUS MCMPmessages can increase traffic congestion on your Apache HTTP Server network.You can configure the
MCMPmessage frequency by modifying theorg.jboss.modcluster.container.catalina.status-frequencyJava system property. By default, the property accepts values that are specified in seconds multiplied by 10. For example, setting the property to1means 10 seconds. In the preceding example, the property is set to6, which means 60 seconds.Optional: To configure the firewall for proxy server advertisements, complete either of the following steps to open port
23364for UDP connections on the worker node’s firewall:For Red Hat Enterprise Linux 7:
firewall-cmd --permanent --zone=public --add-port=23364/udp
firewall-cmd --permanent --zone=public --add-port=23364/udpCopy to Clipboard Copied! Toggle word wrap Toggle overflow For Microsoft Windows using PowerShell
Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "NetSh Advfirewall firewall add rule name="UDP Port 23364" dir=in action=allow protocol=UDP localport=23364"' Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "NetSh Advfirewall firewall add rule name="UDP Port 23364" dir=out action=allow protocol=UDP localport=23364"'
Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "NetSh Advfirewall firewall add rule name="UDP Port 23364" dir=in action=allow protocol=UDP localport=23364"' Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "NetSh Advfirewall firewall add rule name="UDP Port 23364" dir=out action=allow protocol=UDP localport=23364"'Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteWhen a proxy server uses
mod_cluster, the proxy server can use UDP multicast to advertise itself. Most operating system firewalls block the server advertisement feature by default. To enable server advertisement and receive these multicast messages, you can open port23364for UDP connections on the worker node’s firewall, as shown in the preceding examples.
Red Hat Enterprise Linux 6 is no longer supported and subsequently was removed from the documentation.
3.7. Configuring a worker node to operate with a static list of proxy servers 링크 복사링크가 클립보드에 복사되었습니다!
Server advertisement allows worker nodes to discover and register themselves with proxy servers dynamically. If UDP multicast is not available or server advertisement is disabled, you must configure JBoss Web Server worker nodes with a static list of proxy server addresses and ports.
Prerequisites
- You have configured a JBoss Web Server worker node.
- You are familiar with the proxy configuration parameters for Tomcat.
Procedure
-
Open the
JWS_HOME/tomcat<VERSION>/conf/server.xmlfile. To define a
mod_clusterlistener and disable dynamic proxy discovery, add or change theListenerelement forModClusterListener.For example:
<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="false" stickySession="true" stickySessionForce="false" stickySessionRemove="true"/>
<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="false" stickySession="true" stickySessionForce="false" stickySessionRemove="true"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteEnsure that you set the
advertiseproperty tofalse.To create a static proxy server list, update the
proxyListproperty by adding a comma-separated list of proxies in the following format:IP_ADDRESS:PORT,IP_ADDRESS:PORTFor example:
<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="false" stickySession="true" stickySessionForce="false" stickySessionRemove="true" proxyList="10.33.144.3:6666,10.33.144.1:6666"/>
<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="false" stickySession="true" stickySessionForce="false" stickySessionRemove="true" proxyList="10.33.144.3:6666,10.33.144.1:6666"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow