이 콘텐츠는 선택한 언어로 제공되지 않습니다.

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_cluster module is enabled, the mod_cluster Management 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_cluster allows Tomcat servers that have mod_cluster listeners 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_cluster connector 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:

Expand
ComponentDescription

mod_cluster_slotmem.so

The Shared Memory Manager module shares real-time worker node information with multiple Apache HTTP Server processes.

mod_manager.so

The Cluster Manager module receives and acknowledges messages from worker nodes, including node registrations, node load data, and node application life-cycle events.

mod_proxy_cluster.so

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).

mod_advertise.so

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:

Expand
PropertyMaximum character limitDescription

Alias length

100 characters

Alias corresponds to the network name of the respective virtual host; the name is defined in the Host element.

Context length

40 characters

For example, if myapp.war is deployed in /myapp , /myapp is included in the context.

Balancer name length

40 characters

This is the balancer property in mbean.

JVMRoute string length

80 characters

JVMRoute in the <Engine> element.

Domain name length

20 characters

This is the domain property in mbean.

Hostname length for a node

64 characters

This is hostname address in the <Connector> element.

Port length for a node

7 characters

This is the port property in the <Connector> element. For example, 8009 is 4 characters.

Scheme length for a node

6 characters

This is the protocol of the connector. Possible values are http, https, and ajp.

Cookie name length

30 characters

This is the header cookie name for the session ID. The default value is JSESSIONID based on the org.apache.catalina.Globals.SESSION_COOKIE_NAME property.

Path name length

30 characters

This is the parameter name for the session ID. The default value is JSESSIONID based on the org.apache.catalina.Globals.SESSION_PARAMETER_NAME property.

Session ID length

120 characters

A session ID is in the following type of format: BE81FAA969BF64C8EC2B6600457EAAAA.node01

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.

Note

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

Procedure

  1. Open the mod_cluster configuration file.

    Note

    The mod_cluster configuration file is typically located in the JBCS_HOME/httpd/conf.d/mod_cluster.conf directory.

  2. To create a Listen directive for the proxy server, enter the following line in the mod_cluster.conf file:

    Listen IP_ADDRESS:PORT_NUMBER
    Copy to Clipboard Toggle word wrap
    Note

    In the preceding example, replace IP_ADDRESS with the address of the server network interface that the proxy server uses to communicate with the worker nodes, and replace PORT_NUMBER with the port that the proxy server listens on.

    Ensure that the port is open for incoming TCP connections.

  3. To create a virtual host, enter the following details in the mod_cluster.conf file:

    <VirtualHost IP_ADDRESS:PORT_NUMBER>
    
       <Directory />
          Require ip IP_ADDRESS
       </Directory>
    
       KeepAliveTimeout 60
       MaxKeepAliveRequests 0
    
       ManagerBalancerName mycluster
       AdvertiseFrequency 5
       EnableMCPMReceive On
    
    </VirtualHost>
    Copy to Clipboard Toggle word wrap
    Note

    In the preceding example, replace IP_ADDRESS and PORT_NUMBER with the address of the server network interface and port number that you have specified for the Listen directive.

    This address and port combination is only used for mod_cluster management 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.

Note

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

Procedure

  1. Open the mod_cluster configuration file.

    Note

    The mod_cluster configuration file is typically located in the JBCS_HOME/httpd/conf.d/mod_cluster.conf directory.

  2. Add the following directive to the VirtualHost definition:

    ServerAdvertise Off
    Copy to Clipboard Toggle word wrap
    Note

    If 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

Procedure

  1. Open the mod_cluster configuration file.

    Note

    The mod_cluster configuration file is typically located in the JBCS_HOME/httpd/conf.d/mod_cluster.conf directory.

  2. Add the following details to your Apache HTTP Server LogFormat directive(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.
    Copy to Clipboard Toggle word wrap

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.

Note

JBoss Web Server Tomcat worker nodes support only a subset of mod_cluster functionality. Full mod_cluster functionality is available with JBoss EAP.

Procedure

  1. To add a listener to Tomcat, add the following Listener element below the other Listener elements in the JWS_HOME/tomcat<VERSION>/conf/server.xml file:

    <Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="true" stickySession="true" stickySessionForce="false" stickySessionRemove="true" />
    Copy to Clipboard Toggle word wrap
  2. To give the worker node a unique identity, edit the JWS_HOME/tomcat<VERSION>/conf/server.xml file, to add the jvmRoute attribute and value to the Engine element:

    <Engine name="Catalina" defaultHost="localhost" jvmRoute="worker01">
    Copy to Clipboard Toggle word wrap
  3. To configure STATUS MCMP message frequency, modify the org.jboss.modcluster.container.catalina.status-frequency Java system property.

    For example:

    -Dorg.jboss.modcluster.container.catalina.status-frequency=6
    Copy to Clipboard Toggle word wrap
    Note

    Tomcat 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 MCMP messages can increase traffic congestion on your Apache HTTP Server network.

    You can configure the MCMP message frequency by modifying the org.jboss.modcluster.container.catalina.status-frequency Java system property. By default, the property accepts values that are specified in seconds multiplied by 10. For example, setting the property to 1 means 10 seconds. In the preceding example, the property is set to 6, which means 60 seconds.

  4. Optional: To configure the firewall for proxy server advertisements, complete either of the following steps to open port 23364 for UDP connections on the worker node’s firewall:

    • For Red Hat Enterprise Linux 7:

      firewall-cmd --permanent --zone=public --add-port=23364/udp
      Copy to Clipboard Toggle word wrap
    • 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"'
      Copy to Clipboard Toggle word wrap
      Note

      When 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 port 23364 for UDP connections on the worker node’s firewall, as shown in the preceding examples.

Important

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.

Procedure

  1. Open the JWS_HOME/tomcat<VERSION>/conf/server.xml file.
  2. To define a mod_cluster listener and disable dynamic proxy discovery, add or change the Listener element for ModClusterListener.

    For example:

    <Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="false" stickySession="true" stickySessionForce="false" stickySessionRemove="true"/>
    Copy to Clipboard Toggle word wrap
    Note

    Ensure that you set the advertise property to false.

  3. To create a static proxy server list, update the proxyList property by adding a comma-separated list of proxies in the following format: IP_ADDRESS:PORT,IP_ADDRESS:PORT

    For 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"/>
    Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat