Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to route requests via HAproxy to a server that has the lowest latency from the source IP? This seems like a much needed requirement but I can't seem to find anything.

My problem is that our data center is on the West Coast of the United States and we are getting more and more demand from Europe, Asia, and South America, while the latency from these locations is making the application unusable.

share|improve this question
up vote 2 down vote accepted

Given that haproxy proxies requests, all traffic's going to go through haproxy anyway, so sending them to different places isn't going to help you any because all you'll be doing is adding more latency by running the traffic around more than it needs to be. You need to send the user directly to the closest available server, using a geographic or topological DNS engine.

share|improve this answer

you can write your own simple inetd/xinetd script and make haproxy check health of backend server by that script. your own script can check backend machine load, number of connections and so on and decide to accept new traffic or not. hint: this script should behave like very simple http server, you can easily write it in shell. Only methods that you need to implement is 200 response and 500 to pass or deny further requests.

share|improve this answer

HAproxy wouldn't be able to tell what the latency between the end-user and one of your servers would be, since the ping would need to be performed between those two parties.

What you may be able to do is to setup geodns, so that IPs allocated in Europe are sent to your European location, South America ones are sent to your Texas location and so on.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.