May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Crazy way to do JBOSS and Tomcat Loadbalancing :)

Crazy way to do JBOSS and Tomcat Loadbalancing

Mod clusteris an http based load balancer which greatly simplify the setup of an http cluster. It ships as a set of modules which need to be installed on the httpd server and a Service Archive Library (.sar) which needs to be deployed on JBoss AS (It is built-in in JBoss AS 6/7).

Compared with the former mod_jk, the new mod_cluster has the great advantage to accept a dynamic configuration of httpd workers. This can be done through an advertise mechanism where all httpd workers communicate lifecycle events (like startup or shutdown) thus leveraging dynamic configuration of nodes.

 
 
 
What is mod_cluster?
• Set of modules for Apache httpd and a Tomcat-based
webserver
• Apache httpd-2.2.8+
• JBoss AS 5.0.0.GA+, JBoss Web 2.1.1+, Tomcat 6
• Allows httpd to act as a load balancer in front of Tomcatbased
web servers
• similar to mod_jk and mod_proxy_balancer
• JBoss.org project
• http://www.jboss.org/mod_cluster
• LGPL
• Current release is 1.0.0.Beta4
• First Release Candidate expected this month
 

User requests proxied
to backend server
using AJP
• HTTP/HTTPS also
supported
• Request handling on
Java side not affected by
mod_cluster
• Key difference – back
channel from backend
server to httpd
• Lifecycle information
• Load balancing
information
• Uses HTTP or HTTPs

 

1.mod_cluster Profile

        mod_cluster mod_jk, mod_proxy similar httpd-based load balancing project to a proxy request to based on the Tomcat web server cluster (support any independent Tomcat, separate JBoss Web or JBoss AS embedded JBoss Web). the distinction mod_cluster mod_jk and mod_proxy, mod_cluster provide background channel between a web server and httpd server. web server using a background channel httpd end of the current status information.
2.mod_cluster advantages

Able to dynamically configure the httpd tasks: httpd-side without the need to configure each server’s IP and port, auto-discovery mechanism.
2. Provide server-side load weighting factor calculated automatically by the web server side: the server node CPU, memory, jvm stack, database connection pool, thread pool usage, calculate the load weight, can reduce the pressure of the httpd server side
3 the better granularity web application management (event notification mechanism): a web-app deployment / unloading will be notified to the httpd server, so httpd server it would not forward the request to a solution to deploy the application Server, to reduce the time expenditure. Disable and Enable operation and detected the server.
Support AJP, HTTP, HTTPS protocols

3.mod_cluster necessary condition

    * Httpd-2.2.8 +
    * JBoss AS 5.0.0 + or JBossWeb 2.1.1 +
    * Other servers can not be used directly, the need to transform

4.mod_cluster works
5.mod_cluster configure load balancing example with Tomcat

Here only a brief description of mod_cluster + tomcat + ajp protocol + session non-pro + load-demo.war scene detailed installation and configuration refer to the official document: http://docs.jboss.org/mod_cluster/1.1.0/html_single/ # Quick_Start_Guide.
5.1 install httpd server (windows, installing a new the httpd can also upgrade existing httpd, here is the installation of a new httpd)

5.1.1 Download

http://www.jboss.org/mod_cluster/downloads/1-1-0.html download the latest mod_cluster 1.1.0.Final zip bundles

5.1.2 extracting installer

Decompression mod_cluster-1.1.0.Final-windows-x86-ssl.zip, unpacked, there will be a httpd-2.2 directory, execute the its next bin directory under the installation configuration script installconf.bat
5.2 to configure the httpd server

This version of httpd is completely bound mod_cluster component, so long as to httpd_home / conf / httpd.conf to add some mod_cluster load balancing configuration, content and brief description follows (if installed upgrade existing httpd configuration is different, refer to the official documentation for details.):

The Xml code Favorites code

    # For mod_cluster
    # Load necessary. So modules
    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
      
       
    # Set the listener host IP and port
    Listen 192.168.11.24:6666
       
    # Configure virtual host
      
    <VirtualHost 192.168.11.24:6666>
       
      <Directory />
        Order deny, allow
        Deny from all
        # Allow from 127.0.0.1
        Allow from all
      </ Directory>
       
      KeepAliveTimeout 60
      MaxKeepAliveRequests 0
       
    # Declare a load balancer
      ManagerBalancerName mycluster
      AdvertiseFrequency 5
      ServerAdvertise On
      AllowDisplay On
    </ VirtualHost>
       
    # Set the proxy forwards all requests are forwarded to the mycluster load balancer
    ProxyPass / balancer :/ / mycluster /
       
    # The configuration mod_cluster-manager, so that it can access the management page to mod_cluster-manager
    <Location /mod_cluster-manager>
    SetHandler mod_cluster-manager
    Order Deny, Allow
    Deny from all
    Allow from all
    </ Location>

5.3 Installation of the server-side components

http://www.jboss.org/mod_cluster/downloads/1-1-0.html download the latest java mod_cluster 1.1.0.Final, under JBossWeb-Tomcat jar package decompression after copy to tomcat_home / lib.
5.4 Configuring the server-side

Modify tomcat_home / conf / server.xml:
The Xml code Favorites code

    <Listener ClassName=”org.jboss.modcluster.catalina.ModClusterListener” advertise=”true”/> / / add this line configuration
      
     <Engine Name=”Catalina” defaultHost=”localhost” jvmRoute=”tomcat1″> / / in this line configuration add jvmRoute attributes

5.5 visit mod_cluster-manager to view the configuration

Instructions in accordance with 5.3, 5.4, multiple tomcat installed and configured the server-side components, to Note jvmRoute to be configured into different identity. Start the Tomcat Server and httpd, visit the apache mod_cluster-manager page: http://ip:port/mod_cluster-manager <! – @ Import url (scrollbar.css); -> page display mod_cluster to some state information and monitored web server, and each server application, and can Disable and Enable operation of these applications can be dynamically updated in the page, and start and stop the web server and the web-app deployment / uninstall. As shown below:
[Click to view original size picture]

Note: If the page does not display status information mod_cluster Please check whether the set <VirtualHost> </ VirtualHost> AllowDisplay On
5.6 load-demo.war test

the demo directory http://www.jboss.org/mod_cluster/downloads/1-0-3-GA download java mod_cluster 1.0.3.GA Extract Extract demo / server / load-demo.war Executive demo \ client \ the run-demo.bat will pop up a similar LoadRunner graphical interface tools (see the specific use of the official documentation http://docs.jboss.org/mod_cluster/1.1.0/ deploy to each the Tomcat Server html / demo.html), from the test results, apache simulated uniform requests forwarded to the various Tomcat Server. As shown below:

Special Note: Do not use the load-demo.war java mod_cluster 1.1.0.Final this version of the bug the load-demo.war have impossible, I spent a lot of time, it is recommended to use java mod_cluster 1.0.3. GA version of the demo.

6 a app-server with mod_cluster integration needs to do the work

1. To configure a Listerner components.

mod_cluster background channel between the web server and httpd server the background channel need server-side web server to placement a Listerner components (such as tomcat server to need a ModClusterListener components). This component is responsible to interact with the httpd server: for example, to calculate the load weight factor web-app lifecycle status information is pushed to the http server. Now tomcat and jboss provide the configured in server.xml Listener:

The Xml code Favorites code

    <Listener ClassName=”org.jboss.modcluster.catalina.ModClusterListener” advertise=”true”/>

TongWeb configuration file and management console did not to provide configure the Listener place, but com.tongweb.web.core.core.StandardServer in providing addLifecycleListener () method can be added lifecycle Listener.

2. Transformation mod_cluster provide the server-side components

Rely on some source of tomcat or jboss simple to view the server-side components provided mod_cluster jar package source code, which is part of the source code example, ModClusterListener has some dependencies:

 

 

Advantages of mod_cluster vs mod_jk

Hello All,
       Maximum times I have heard about mod_jk. So, I was a little bit confused that which one better and better performer than others. So I have just searched and found really good and interesting answer and sharing this as below. So if anyone knows something interesting or new about the comparison of these both, then please share your thoughts.
 

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.
 

 

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. Consequently, mod_cluster offers a more robust and accurate set of load metrics than is available from the proxy. (see Load Metrics for more)
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.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>