I am using two apache tomcat servers on two windows 7 machines and want to load balance the requests for those servers through a load balancer. I am not that experienced in building up such networks but want to give it a try. Actually I just have two real computers. So is there a way to run the load balancer in a virtual machine or something?
2 Answers
It's useful to run a load balancer that can implement "sticky sessions" by sending repeated requests from the same user to the same server. Basically it has to recognize the JSESSIONID cookie as a session cookie.
I do load balancing using mod_ajp with the Apache httpd web server. You can run this on linux or windows. (I have a Linux front web server that load balances among various Linux and Windows app servers).
-
Yes, use Apache with mod_proxy and mod_proxy_ajp. You can run it on either of the two machines, and have it balance between its own host and the other one. If you need sticky sessions (you probably do, unless you're doing something else to share sessions), take a look at the jvmRoute Engine attribute for Tomcat, and the stickysession and route attributes for mod_proxy in Apache httpd. This page has a good example: wellho.net/archives/2009/10/load_balancing_2.html Nov 13, 2010 at 5:20
On Windows, you can use NLB to create a virt between the two machines. Alternately, anything that can sit in front of the servers (logically; it can be cabled/networked as a peer) can run load-balancing software. Most LB software of which I'm aware runs on Linux, so if you wanted to run it off of a virt, that's certainly an option.
If you're running Tomcat on Win7, the correct answer is usually either to scale vertically (i.e., make one of those machines beefier) or to move to a more robust platform where Tomcat performs better--e.g., *NIX. That said, nothing to say you aren't just trying to learn about load-balancing here, or that there aren't other considerations at work, so this is just a suggestion.