1

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.

1

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.

  • Ah! So all I have to do is implement a little TCP service that reports the current state of the machine through the agent-check feature. That's much better than the PHP "trick" proposed by jbrahy. – Alexis Wilke Sep 18 '16 at 19:15
  • «some kind of server response time algorithm» — I think that's the point of a feature such as the agent-check. One cannot really know how loaded a server is without asking it. The network connections may work just fine because it runs just a few thousand assembly instructions and it's done. So a heavy load on a server does not automatically prevent a quick connection from working just fine. – Alexis Wilke Sep 18 '16 at 19:19
1

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.

Your Answer

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

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