Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Load balancing Red Hat JBoss Enterprise Application Platform subclusters with mod_cluster

July 15, 2020
Pandurang Memane
Related topics:
JavaContainersDevOps

Share:

    This article introduces a way to build and manage clustered environments using subclusters in a domain-mode installation of Red Hat JBoss Enterprise Application Platform (JBoss EAP). I assume that readers are familiar with JBoss EAP and the Apache HTTP Server (HTTPD) mod_cluster module. I introduce the load balancing group configuration for that module.

    Using mod_cluster in a subcluster without the load balancing group

    Consider that there are two subclusters: One subcluster hosts server1 and server2, and the other subcluster hosts server3 and server4. Suppose the first request is served by server1. If server1 fails, then the request will transfer to another node using the mod_cluster load-balancing algorithm of bybusyness (bydefault). This algorithm tries to intelligently determine the best node available for a given request.

    If the mod_cluster algorithm determines that server3 is the best node to transfer the request to, then the request will transfer to server3. Even if the server2 node was available (up and running), the request would go to the server3/server4 node in the second sub-cluster, and since there is no session replication between server1 and server3/server4, a new session is created and the existing session would logout.

    In the next sections, I will you how to overcome this issue by inserting a load balancing group at the JBoss EAP level. Configuring the mod_cluster to send requests through a load balancing group ensures that a request is sent to the next node in a given subcluster before it is sent to another subcluster.

    Using mod_cluster in a subcluster with the load balancing group

    In this scenario, the mod_cluster is configured to send requests through the load balancing group. Figure 1 shows the two subclusters, with server1 and server2 in one subcluster, and server3 and server4 in another subcluster. Suppose the requests are served by server1. If requests are served fine, but somehow server1 fails or goes down, then the same requests will transfer to server2. The difference is that the mod_cluster module knows the subcluster member through the load balancing group.

    An architectural diagram

    Figure 1: An example configuration with the mod_cluster directing requests through the load balancing group to two different server groups.

    An example subcluster at the JBoss EAP level

    Consider an example setup where we have two subclusters with two nodes each per subcluster. We begin to set up a domain with four servers. The first server is the domain controller, and the other three are normal hosts. Each subcluster is represented by a server group and built by two server groups, namely SubCluster1 and SubCluster2. Later, we edit the host.xml on the nodes and add servers to each group. On starting JBoss EAP, we observe an abnormality: All three servers replicate each other. What's more, the cluster is not scalable but is more available than we need it to be. We can use subclusters to correct this abnormality.

    Using subclusters for load balancing

    By default, the multicast at the modcluster subsystem level values all nodes of all subclusters to be seen by the Apache HTTPD mod_cluster module. It is implied that the mod_cluster will manage load balancing. The mod_cluster looks for all of the nodes that would have the same application deployed. It assumes that it can do failover and all other features on all the nodes of all of the subclusters.

    Configure the mod_cluster subsystem

    To build and manage JBoss EAP clustered environments using subclusters, we need to configure the JBoss EAP servers' modcluster subsystem to have each subcluster in a different load balancing group. We can achieve this by adding in the domain.xml in our required profile:

    <subsystem xmlns="urn:jboss:domain:modcluster:4.0">
        <proxy name="default" advertise-socket="modcluster" listener="ajp" load-balancing-group="${mycluster.modcluster.lbgroup:StdLBGroup}" proxies="proxy1">
            <dynamic-load-provider>
                <load-metric type="cpu"/>
            </dynamic-load-provider>
        </proxy>
    </subsystem>

    Set the server group properties

    Next, we create two server groups with two different load balancing groups in the domain.xml—LBGroup1 and LBGroup2. Now, it is up to us to use the same profile or socket-binding group in different versions, which means we must first set the server group's properties. Setting the properties is simple and self-explanatory:

    <server-group name="SubCluster1" profile="ha">
        <socket-binding-group ref="ha-sockets"/>
        <system-properties>
            <property name="jboss.default.multicast.address" value="230.0.0.7"/>
            <property name="mycluster.modcluster.lbgroup" value="LBGroup1"/>
        </system-properties>
    </server-group>
    <server-group name="SubCluster2" profile="ha">
        <socket-binding-group ref="ha-sockets"/>
        <system-properties>
            <property name="jboss.default.multicast.address" value="230.0.0.8"/>
            <property name="mycluster.modcluster.lbgroup" value="LBGroup2"/>
        </system-properties>
    </server-group>

    Create the servers in host.xml

    Next, we create the servers in the host.xml: Server1 and Server2 in the SubCluster1 server group, and Server3 and Server4 in the SubCluster2 server group:

        <server name="Server1" group="SubCluster1" auto-start="true">
             <socket-bindings socket-binding-group="ha-sockets"/>
        </server>
        <server name="Server2" group="SubCluster1" auto-start="true">
             <socket-bindings socket-binding-group="ha-sockets" port-offset="100"/>
        </server>
        <server name="Server3" group="SubCluster2" auto-start="true">
             <socket-bindings socket-binding-group="ha-sockets" port-offset="200"/>
        </server>
        <server name="Server4" group="SubCluster2" auto-start="true">
             <socket-bindings socket-binding-group="ha-sockets" port-offset="300"/>
        </server>

    Check the results

    If we have configured the domain.xml and host.xml as described, the mod_cluster page should now look like the screenshots in Figure 2 and Figure 3.

    The LBGroup1 subcluster has server1 and server2
    Figure 2: The LBGroup1 subcluster has server1 and server2.

     

    The LBGroup2 subcluster has server3 and server4
    Figure 3: The LBGroup2 subcluster has server3 and server4.

    Conclusion

    When you are creating your servers, make sure that all the servers in the subcluster are present in the same load balancing group. Also, make sure that you have a working mod_cluster module before implementing the changes that I have described.

    Last updated: July 13, 2020

    Recent Posts

    • How to run AI models in cloud development environments

    • How Trilio secures OpenShift virtual machines and containers

    • How to implement observability with Node.js and Llama Stack

    • How to encrypt RHEL images for Azure confidential VMs

    • How to manage RHEL virtual machines with Podman Desktop

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue