Thursday, February 28, 2008

Load balancing

I surprised myself when I read my old post (wrote it on 28 Feb 2008). What was I thinking? never met someone who use load balancer?? I must had a very small view of the IT world ;)

"A nice article on load balancing with apache, somehow until now I never met someone who use load balancer (even on a big project) and this makes me think... do we really need a load balancer? What are the cases where load balancer is really required?
It seems that upgrading the server is the preferred choice, personally I'm waiting for a chance where I can setup a load balancer :) One more thing that I'm looking forward to see is transparent failover, hopefully I'll see one sooner rather than later."

Now, I stand corrected, load balancer is a must and how do we have a scalable architecture without one?
For my own needs, one of the cheapest solution I believe is to use Apache httpd as a load balancer for my application servers. Here's how to set it up:

1. Edit apache's httpd.conf and below is a sample configuration


 2. Load the modules below by uncommenting them in the LoadModule section in httpd.conf:
- mod_proxy.so
- mod_proxy_balancer.so
- mod_proxy_ajp.so 
- mod_proxy_http.so
- mod_lbmethod_bytraffic.so
- mod_slotmem_shm.so
3. Make sure ajp connector is enabled in Tomcat's server.xml configuration file.
4. Restart apache httpd

I think that's all we need.


Reference:
- http://httpd.apache.org/docs/2.2/mod/mod_proxy_balancer.html
- http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxyset

No comments: