Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have three small questions that relate to the same topic:

  1. With HAProxy, is there any way to load balance based on the current load of the different servers (ie. routing a request to the least loaded server).
  2. If not, why isn't this behaviour built into HAProxy? Are there any major performance impacts of doing this? I imagine rather than for example, the instead of looking for the least connections (leastconn algorithm), that I'd be looking for the lowest load.
  3. If there are no major performance impacts of doing this, is my assumption that one could build this functionality into a custom HAProxy distribution without affecting performance correct?
share|improve this question

migrated from stackoverflow.com Oct 26 '11 at 15:16

This question came from our site for professional and enthusiast programmers.

1 Answer 1

The only way to do this with haproxy is create a script that haproxy's health check checks. In the script you are checking the load average and if it's a valid load.. return a response code of 200. If it is too high return a 404 or 500 error. Your haproxy check would look something like

option httpchk HEAD /health_check.php HTTP/1.0

if haproxy sees any 2xx/3xx response it will be valid.. anything else it will take that node offline till the node's load goes down and the health_check.php scripts returns a 200

share|improve this answer

Your Answer

 
discard

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