TechDocs


   Rubrik > Development > Java >


    09.09.2011 16:20:38  Development > Java    

Tomcat Cluster with Apache HTTP load balancer (mod_jk)

Apache HTTP Server works for the following reasons in front of a tomcat server cluster:

  • static content will be delivered faster by a Apache HTTP server
  • the Apache webserver can work as a Load Balancer for a Tomcat cluster and will forward requests to multiple tomcat server in the backend

For load balancing the Apache webserver has to load the mod_jk modul. With the Apache mod_jk load balancer modul loaded the requests can forwarded through the AJP 1.3 protocol to one or multiple Tomcat server.

All the Tomcat worker in cluster needs a open AJP 1.3 connector port. The Apache mod_jk modul gets the Tomcat connector port of the Tomcat worker instances from a 'worker.properties' file. The 'workers.properties' file has to be created and configured for the cluster and the Apache Tomcat bridge.

Similar links:
  => Configure Sticky Sessions in a Tomcat Cluster
  => Session Replication in Tomcat Cluster
  => Running multiple Tomcat instances on a server
  => JkStatusManager - Apache Load Balancer Monitoring


Apache HTTP webserver configuration

Create a config file 'tomcat_jk.conf' and append it to the $APACHE_HOME/conf/httpd.conf configuration file:

 Include /etc/apache2/tomcat_jk.conf

The 'tomcat_jk.conf' file loads the load balancer 'mod_jk' modul at Apache server startup. The newest 'mod_jk' modul could be found on the Apache Tomcat Homepage. Store the 'mod_jk' dynamic library modul in the appropriate Apache webserver modules folder '/usr/lib/apache2/mod_jk.so'.
tomcat_jk.conf

The load balancer and Tomcat parallel worker configuration and connectivity properties are specified in a 'worker.properties' file. Name and location of 'workers.properties' file is defined in the 'tomcat_jk.conf' config file of the Apache's webserver.
worker.properties


Tomcat configuration

Activate in the 'conf/server.xml' files of all Tomcat server the Connector for the AJP 1.3 protocol.
server.xml

After Apache and Tomcat server instances restart the load balancer is active.
Here's a example for restarting on linux:

 $ /etc/init.d/apache2 restart
 $ /etc/init.d/tomcat restart

There is no order for restarting.

Similar links:
  Configure Sticky Sessions in a Tomcat Cluster
  Session replication in a Tomcat Cluster
  Running multiple Tomcat instances on a server
  JkStatusManager - Apache Load Balancer Monitoring



Übersicht