I'm wondering whether there would be an advantage or not to know the loadavg of each backend server and ask HAProxy to send the next request to the computer with the lowest loadavg.
However, I have not seen anything that would offer such a capability in HAProxy. Maybe it is not available?
I have found this post that shows a frontend definition with a use_backend
command, but I am thinking that the map is going to be loaded once and cached for the whole duration of the HAProxy run. In otherwise, dynamically changing the map sorting the items by loadavg would make no difference...
frontend ft_items
[...]
use_backend %[path,lower,map(/etc/haproxy/items.map,bk_default)]
It is not clear to me that roundrobin would be good enough for my application because some requests take 50ms (images, CSS, etc.) and others can take a good 2s (Large Reports). So checking the loadavg of a computer seems more likely to fit the bill of this application.
You would be better off breaking the HAProxy maps up so that quick requests for static resources go via one round robin map and slower requests via a different RR map.
You can use the same or different backend pools for the requests, the idea being that on average all servers are handling the same amount of fast and slow requests. Alternatively you can map them to different backend systems and use more powerful systems for the computationally intensive work of the reports.
Alexis,
This sounds exactly like what agent-check is meant to be used for. Willy kindly added the patch we use for the Loadbalancer.org appliance and we have open sourced our Windows based server agent. The instructions including a basic Linux server example are here:
https://www.loadbalancer.org/blog/open-source-windows-service-for-reporting-server-load-back-to-haproxy-load-balancer-feedback-agent
The Windows agent can monitor a combination of CPU, RAM & TCP connection counts (i.e. for RDP sessions).
Feedback is always welcome. This reminds me - it would be nice if someone implemented some kind of server response time algorithm, then you wouldn't necessarily need a server based agent.