Load balancing JBoss and Apache2 / mod_jk
2010-10-23 13:03
Write commentHaving more and more needs to deploy high load and critical applications, clustering JBoss in a load balancing mode is becoming a priority.
I will discuss a good old way to use mod_jk on Apache2 to balance the load on multiple JBoss servers, there's also different newish approaches using mod_proxy or mod_cluster from JBoss that i will discuss in future posts.
So let's start installing JBoss AS, you have to download it from the official site here, i've taken the last 6.x release (6.0.0.M5) to the date i'm writing this post, anyway you can even take a 5.x release as it has no difference for what we're going to make later.
After downloading, put the file into your /opt folder and unpack it, you'll get a /opt/jboss-6.0.0.20100911-M5, we'll try to run the JBoss AS server and check if it runs out of the box:
# cd /opt/jboss-6.0.0.20100911-M5/bin
# sudo ./run.shWait some seconds, you shouldn't have errors till you get the last line looking like this: Started in 51s:29ms.
Everything seems okay, now we'll start the second JBoss server, all we have to do is to copy the jboss-6.0.0.20100911-M5 to another server (i use virtual nodes over Xen hypervisor) and start it.
You can go with one server and install two instances of JBoss AS on it, but dont forget to change the listening ports of the second instance to avoid this kind of errors: java.lang.Exception: Port 8080 already in use.
Anyway, whatever configuration you've chosen, we should end with an architecture like this:

Everything is okay ? let's go to Apache:



