Tomcat – Deciding for software load balancing solution (apache mod vs other)

apache-2.2haproxyload balancingtomcat

I have a simple web server configuration with Apache webserver and Tomcat. For instance we have 2 servers. I plan to scale up. Of course we will need a load balancing solution very soon. Should I be fronting Tomcat servers with Apache for load balancing or use something else?

Is there a reason I should use some external software like HaProxy for load balancing instead of the, say mod_proxy_http, for apache server? When you search for load balancing in Linux env. you find a lot of stuff for Haproxy but not for Apache server, why!?

thank you!

Best Answer

HAProxy uses a single process event based model whereas with something like Apache I believe you have thread based (mpm_worked) or process based (prefork). Assuming I am correct in that mod_proxy will still be based off threads or processes for each connection (I could be totally wrong about this one), that is going to take a lot more system resources when you get to higher load levels.

Also, from my personal experience something that is built to do something particular often excels at doing that one thing than more of a swiss-army knife solution. So for example with HAProxy you have various options about how keep-alive connections are handled between the clients and the load balancer and between the load balancer and the servers. I am not sure if something like mod_proxy will offer this sort of flexibility.