2 Tomcat with single Apache with load balancing ???
We want to implementing the load balancing for our domain, if the traffic is heavy and 8080 (i.e. currently integrated with apache) doesn''t serve more that time the apache will call 8081 and serve to the request without any problem.
We want to access our site www.domain.com (i.e. run on port 80). Please guide us it is possible or not ?
Here is a setup that I've done using Glassfish (also a Java application server running on port 8080) and it works pretty well for me.
In my case I used 3 separate machines, but you can just as well use a single machine.
maxconn 8192 # Total Max Connections. This is dependent on ulimit
nbproc 2 # Number of processing cores. Dual Dual-core Opteron is 4 cores for example.
option httpclose # Disable Keepalive
listen http_proxy 0.0.0.0:80
balance roundrobin # Load Balancing algorithm
option forwardfor # This sets X-Forwarded-For
## Define your servers to balance
server wdc1 wdc1:8080 weight 1 maxconn 2048 check
server wdc2 wdc2:8080 weight 1 maxconn 2048 check
wdc1 and wdc2 are in the /etc/hosts file in this case.
in your case you should use:
server tomcat1 127.0.0.1:8080 weight 1 maxconn 2048 check
server tomcat2 127.0.0.1:8081 weight 1 maxconn 2048 check
HAProxy will check both servers and will not serve traffic to those who are not responding properly.