We're currently using HAproxy to load balance our image and application servers, but we haven't setup failover. We currently just have haproxy on one of the image boxes which then routes the requests where they need to go. Now, next week we are moving to our new colo (14 servers, it's time to stop leasing hardware).

We have 5 front end application servers. is it possible for me to put haproxy on two of those boxes, have a shared ip for failover, and simply move apache to port 9000 or some other arbitrary port? We're already at our budget for the colo for the next couple months, so I would like to avoid having two dedicated boxes for JUST HAproxy if we can avoid it.

The 5 application servers house apache and sphinx. The application servers them communicate with our mysql servers and our growing cassandra cluster.


HAProxy doesn't care if the web servers are on the local machine. Adding Apache to the same machine and using different ports is perfectly valid. Some day you may want to dedicate HAProxy but you probably don't need to yet (HAProxy has very low resource usage for Stack Overflow Currently).

Another option besides the multiple ports would be to have multiple IPs on each machine and bind to those. You can bind to a:

  • wildcard ip and a specific port
  • wildcard port and a specific ip
  • wildcard port and wildcard ip
  • specific ip and specific port

Also to bind to a specific VIP (Virtual failover IP) you will want the following in /etc/sysctl.conf:


| improve this answer | |
  • Thanks, I hadn't considered the separate ip approach. That would work fine, we have an entire class C :D – user60903 Nov 19 '10 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy