# Leastconn algorithm for short lived connections

**URL:** <https://discourse.haproxy.org/t/leastconn-algorithm-for-short-lived-connections/3426>\
**Category:** Help!\
**Created:** [January 24, 2019, 6:43am UTC](https://discourse.haproxy.org/t/leastconn-algorithm-for-short-lived-connections/3426 "2019-01-24T06:43:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skinnyguinea](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@Skinnyguinea](https://discourse.haproxy.org/u/Skinnyguinea)\
**Post date:** [January 24, 2019, 6:43am UTC](https://discourse.haproxy.org/t/leastconn-algorithm-for-short-lived-connections/3426/1 "2019-01-24T06:43:50Z")

</div>

Hi all,

We have configured HA Proxy for forwarding connections to two application servers.

We have used roundrobin algorithm for the balance parameter in the backend code section.

We wish to know if we can use leastconn algorithm for this purpose.

The connections are of a short duration and we are aware that leastconn is generally used for long running sessions.

Can we replace roundrobin with leastconn in our config file? What kind of behaviour can we expect if we were to implement this?

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [January 25, 2019, 7:27pm UTC](https://discourse.haproxy.org/t/leastconn-algorithm-for-short-lived-connections/3426/2 "2019-01-25T19:27:04Z")

</div>

Sure you can, just do it and monitor the numbers closely after the modification.

Usually you don’t need leastconn for short lived connections, but if you want, you can certainly use it.

---

<div class="post-metadata">

**Author:** ![Skinnyguinea](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@Skinnyguinea](https://discourse.haproxy.org/u/Skinnyguinea)\
**Post date:** [January 29, 2019, 6:55am UTC](https://discourse.haproxy.org/t/leastconn-algorithm-for-short-lived-connections/3426/3 "2019-01-29T06:55:44Z")

</div>

Thanks Lukas!
