Reputation: 11
Background: In my application, I use ServiceMix instances to serve HTTP requests. To load balance these, we figured out(according to some requirement) that we need to use Tomcat.
Question: As I think it should be said that tomcat has its own http server built into it, can Tomcat and mod_jk(without Apache Http Server) be used as a load balancer?
My readings: I read few of the Tomcat domcumentation like Tomcat Clustering doc , Tomcat JK load balancer (which wasn't quite helpful)
So I wonder is it even possible to use only Tomcat and mod_jk for the purpose of load balancing!!
Any help is appreciated.
Upvotes: 1
Views: 4897
Reputation: 6484
To load balance your application you'll need to run two or more Tomcat instances with the same application. You could run two instances on the same machine on different ports (e.g. www.myapp.com:8080 and www.myapp.com:9090) or on different machines on the same port (e.g. www1.myapp.com:8080 and www2.myapp.com:8080). Usually the instances share the same backend data store. Each Tomcat is its own webserver, so you'll have multiple web servers running.
Because you now have two identical instances a user can use either of the two instances. They can also switch from one to the other if something happens to the machine they are currently using. But you don't want your users to have to choose a machine or swap manually. This is where a load balancer comes in.
A load balancer takes a request from the user and dynamically routes it to one of your load balanced instances. A load balancer is also a web server. It can be a hardware load balancer like a BIG-IP F5, or software like Apache, nginx or even another Tomcat server.
If you use an Apache web server to do the load balancing you'll need an Apache module to pass on the request to one of your Tomcat servers. Typically this is mod_jk or mod_proxy.
So the short answer is that if you use Apache as your load balancer then you have to use mod_jk (or mod_proxy). If you use another load balancer then you can't use mod_jk.
Also refer to Tomcat load balancer solutions
Upvotes: 2
Reputation: 62692
mod_jk runs inside of apache httpd server or some other server it is written in native code, Here are some configurations that will work.
For load balancing you need to make sure to determine weather you need sticky session routing or not.
Also you do don't need to configure tomcat clustered session manager in order to configure and use load balancing.
I am fairly certain that tomcat itself the java part does not ship with a built in load balancer it expect users to use one of the above options.
Upvotes: 1