HA Proxy – roundrobin vs leastconn

haproxyhigh-loadload balancing

Are there any suggestion on when should I use roundrobin & when should I use leastconn?

I am using roundrobin currently and observed the loading of my back-end servesr are not evenly distribution. Of course there might be other issue, but we want to give leastconn a try, but as it is a mission critical server, I want to consult other experience before making the changes.

Any idea to share?

Best Answer

I haven't experimented with leastconn, but my understanding is that the typical use case for leastconn is when you are load balancing something that can have long lived connections. The reason for this is that leastconn focus on ensuring balanced concurrency where as road robin is going provide a more balanced arrival rate. If this distinction isn't clear, see my answer on the difference.

When you say the load is not evenly distributed, it might help to define "load" a little bit better. If you mean server resources, than I suggest identifying what exactly is causing the increased load (i.e. certain types of connections) and working backwards from there.