Alexander Meise
Alexander Meise

Reputation: 1438

tomcat cluster apache in front - How to load balance?

What apache module would fit better to build the following cluster: 2x Red Hat each has a tomcat an apache. No Scalability needs. High availability needs. Session replication needs.

          DNS
           |
     Load Balancer
      /           \
  APACHE1      APACHE2
  TOMCAT1      TOMCAT2

The question is regarding what module to use for the load balancing with apache?

mod_proxy mod_cluster other?

Upvotes: 0

Views: 860

Answers (1)

Christopher Schultz
Christopher Schultz

Reputation: 20882

If I understand mod_cluster correctly, it must be used with JBoss, or with a modified Tomcat. So if you are using plain-old Tomcat (or TomEE), then I think mod_cluster is out.

The easiest out-of-the box option is to use mod_proxy with either the AJP or HTTP back-end. If you are comfortable building additional modules, mod_jk is available from the Tomcat folks and offers a few advantages over mod_proxy, though mod_proxy has nearly achieved feature-parity.

Your diagram suggests that a load-balancer will be choosing between two httpd instances which are coupled directly to a single Tomcat instance each. In that scenario, httpd is not performing any load-balancing at all (the lb is doing the work), and so httpd might be superfluous in that configuration.

If you instead want to cross-link both httpds with both Tomcats, that's when you start having to configure cluster-like behavior with mod_proxy's "balancer" configurations. It would look something like this:

<Proxy balancer://appA>
  BalancerMember http://tomcatA:8080/appA
  BalancerMember http://tomcatB:8380/appA
</Proxy>

ProxyPass /appA balancer://appA
ProxyPassReverse /appA balancer://appA

There are tons of options for mod_proxy that you should read about and apply to suit your configuration. You can configure things like sticky-sessions, hot-standbys (not present in your example diagram but a good idea if you really need HA), and asymmetric load-balancing.

Upvotes: 1

Related Questions