# Haproxy Remote Desktop services 2016 not balancing

**URL:** <https://discourse.haproxy.org/t/haproxy-remote-desktop-services-2016-not-balancing/2454>\
**Category:** Help!\
**Created:** [May 3, 2018, 7:56pm UTC](https://discourse.haproxy.org/t/haproxy-remote-desktop-services-2016-not-balancing/2454 "2018-05-03T19:56:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![freestyle](https://avatars.discourse-cdn.com/v4/letter/f/b19c9b/32.png) [@freestyle](https://discourse.haproxy.org/u/freestyle)\
**Post date:** [May 3, 2018, 7:56pm UTC](https://discourse.haproxy.org/t/haproxy-remote-desktop-services-2016-not-balancing/2454/1 "2018-05-03T19:56:30Z")

</div>

Hi  
I have 8 windows 2016 Remote Desktop servers and I’m using 1.8 haproxy to try and load balance using leastconn.

The first 24 connections got balanced nicely… but then most of the connections started to go to server4…

I commented out server4 from the config and did a reload…

The next set of connections started to balance on the other servers but then I noticed a lot of the connections started to hit server3…

Just wondering if anyone has come across this before

Cheers

---

<div class="post-metadata">

**Author:** ![shivharsh](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/shivharsh/32/388_2.png) [@shivharsh](https://discourse.haproxy.org/u/shivharsh)\
**Post date:** [May 4, 2018, 4:58am UTC](https://discourse.haproxy.org/t/haproxy-remote-desktop-services-2016-not-balancing/2454/2 "2018-05-04T04:58:22Z")

</div>

Hi,  
It would be helpful if you could share the following information:

1. HAProxy logs for the duration when the requests start landing on a single server instead of being load balanced.  
`[root@ha haproxy]# cat /var/log/haproxy/haproxy.log`
2. HAProxy stats and info for the duration when the requests start landing on a single server instead of being load balanced.  
`[root@ha haproxy]# echo "show info" | socat unix-connect:/run/haproxy/admin.sock stdio`  
`[root@ha haproxy]# echo "show stat" | socat unix-connect:/run/haproxy/admin.sock stdio`  
For above commands you would need to install socat utility and expose stats over socket, if not done already.  
To expose haproxy stats add following line to the global section of your configuration:  
`stats socket /run/haproxy/admin.sock level admin`
3. The haproxy configuration file.  
`[root@ha ~]# cat /etc/haproxy/haproxy.cfg`

Thanks,  
Shivharsh

---

<div class="post-metadata">

**Author:** ![freestyle](https://avatars.discourse-cdn.com/v4/letter/f/b19c9b/32.png) [@freestyle](https://discourse.haproxy.org/u/freestyle)\
**Post date:** [May 4, 2018, 6:05am UTC](https://discourse.haproxy.org/t/haproxy-remote-desktop-services-2016-not-balancing/2454/3 "2018-05-04T06:05:03Z")

</div>

With the below, more sessions were connecting to RDSH3 (I commented out RDSH4) and reloaded it.

show\_stat

# pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate\_lim,rate\_max,check\_status,check\_code,check\_duration,hrsp\_1xx,hrsp\_2xx,hrsp\_3xx,hrsp\_4xx,hrsp\_5xx,hrsp\_other,hanafail,req\_rate,req\_rate\_max,req\_tot,cli\_abrt,srv\_abrt,comp\_in,comp\_out,comp\_byp,comp\_rsp,lastsess,last\_chk,last\_agt,qtime,ctime,rtime,ttime,agent\_status,agent\_code,agent\_duration,check\_desc,agent\_desc,check\_rise,check\_fall,check\_health,agent\_rise,agent\_fall,agent\_health,addr,cookie,mode,algo,conn\_rate,conn\_rate\_max,conn\_tot,intercepted,dcon,dses,

ft\_rdp,FRONTEND,5,25,2000,12549,610227160,26344663458,0,0,0,OPEN,1,2,0,0,0,0,6,0,0,0,0,0,0,0,tcp,0,6,12549,0,0,  
bk\_rdp,RDSH1,0,0,1,2,659,36155611,114621275,0,0,652,0,0,UP,1,1,0,1,0,120191,0,1,3,1,659,2,0,2,L7OK,0,0,6,652,2691,(tcp-check),0,0,0,66930,Layer7 check passed,2,3,4,172.29.101.1:3389,tcp,  
bk\_rdp,RDSH2,0,0,0,7,1399,150398669,6880928592,0,0,1396,0,0,UP,1,1,0,0,0,120191,0,1,3,2,1382,2,0,2,L7OK,0,0,3,1396,44,(tcp-check),0,0,0,331399,Layer7 check passed,2,3,4,172.29.101.2:3389,tcp,  
bk\_rdp,RDHS3,0,0,1,13,338,83446582,17594671089,0,0,335,0,0,UP,1,1,0,0,0,120191,0,1,3,3,312,2,0,4,L7OK,0,0,2,335,10,(tcp-check),0,1,0,556863,Layer7 check passed,2,3,4,172.29.101.3:3389,tcp,  
bk\_rdp,RDSH5,0,0,0,3,1488,101349017,507625097,0,0,1482,0,0,UP,1,1,0,0,0,120191,0,1,3,4,1488,2,0,3,L7OK,0,0,6,1482,10,(tcp-check),0,1,0,84971,Layer7 check passed,2,3,4,172.29.101.5:3389,tcp,  
bk\_rdp,RDSH6,0,0,1,3,2202,119547500,528569090,0,0,2191,0,0,UP,1,1,0,0,0,120191,0,1,3,5,2201,2,0,3,L7OK,0,0,9,2191,24,(tcp-check),0,0,0,51419,Layer7 check passed,2,3,4,172.29.101.6:3389,tcp,  
bk\_rdp,RDSH7,0,0,1,2,2029,95971214,385162770,0,0,2020,0,0,UP,1,1,0,0,0,120191,0,1,3,6,2029,2,0,2,L7OK,0,0,6,2020,22,(tcp-check),0,1,0,39196,Layer7 check passed,2,3,4,172.29.101.7:3389,tcp,  
bk\_rdp,RDSH8,0,0,1,2,251,23358567,333085545,0,0,240,0,0,UP,1,1,0,0,0,120191,0,1,3,7,250,2,0,3,L7OK,0,0,10,240,2691,(tcp-check),0,1,0,188960,Layer7 check passed,2,3,4,172.29.101.8:3389,tcp,  
bk\_rdp,BACKEND,0,0,5,25,200,12549,610227160,26344663458,0,0,0,8316,0,0,UP,7,7,0,0,120191,0,1,3,0,8321,1,0,6,42,8316,0,0,0,0,10,0,1,0,247702,tcp,leastconn,  
stats,FRONTEND,0,1,2000,12,64250,2548077,0,0,0,OPEN,1,4,0,0,0,0,1,0,114,0,0,0,0,0,4,114,0,0,0,0,http,0,1,12,114,0,0,  
stats,BACKEND,0,0,0,0,200,0,64250,2548077,0,0,0,0,0,0,UP,0,0,0,0,120191,1,4,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30787,0,0,0,238,http,roundrobin,

show\_info  
Name: HAProxy  
Version: 1.7.11-1ppa1~xenial  
Release\_date: 2018/04/30  
Nbproc: 1  
Process\_num: 1  
Pid: 1900  
Uptime: 1d 9h22m34s  
Uptime\_sec: 120154  
Memmax\_MB: 0  
PoolAlloc\_MB: 0  
PoolUsed\_MB: 0  
PoolFailed: 0  
Ulimit-n: 4039  
Maxsock: 4039  
Maxconn: 2000  
Hard\_maxconn: 2000  
CurrConns: 5  
CumConns: 12556  
CumReq: 12670  
MaxSslConns: 0  
CurrSslConns: 0  
CumSslConns: 0  
Maxpipes: 0  
PipesUsed: 0  
PipesFree: 0  
ConnRate: 0  
ConnRateLimit: 0  
MaxConnRate: 6  
SessRate: 0  
SessRateLimit: 0  
MaxSessRate: 6  
SslRate: 0  
SslRateLimit: 0  
MaxSslRate: 0  
SslFrontendKeyRate: 0  
SslFrontendMaxKeyRate: 0  
SslFrontendSessionReuse\_pct: 0  
SslBackendKeyRate: 0  
SslBackendMaxKeyRate: 0  
SslCacheLookups: 0  
SslCacheMisses: 0  
CompressBpsIn: 0  
CompressBpsOut: 0  
CompressBpsRateLim: 0  
ZlibMemUsage: 0  
MaxZlibMemUsage: 0  
Tasks: 19  
Run\_queue: 1  
Idle\_pct: 100  
node: PNT-AP62

haproxy.cfg  
global  
log /dev/log local0  
log /dev/log local1 notice  
chroot /var/lib/haproxy  
stats socket /run/haproxy/admin.sock mode 660 level admin  
stats timeout 30s  
user haproxy  
group haproxy  
daemon

```
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private

# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL). This list is from:
# https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
# An alternative list with additional directives can be obtained from
# https://mozilla.github.io/server-side-tls/ssl-config-generator/?server=haproxy
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS
ssl-default-bind-options no-sslv3

```

defaults  
log global  
mode http  
option httplog  
option dontlognull  
timeout connect 5000  
timeout client 50000  
timeout server 50000  
errorfile 400 /etc/haproxy/errors/400.http  
errorfile 403 /etc/haproxy/errors/403.http  
errorfile 408 /etc/haproxy/errors/408.http  
errorfile 500 /etc/haproxy/errors/500.http  
errorfile 502 /etc/haproxy/errors/502.http  
errorfile 503 /etc/haproxy/errors/503.http  
errorfile 504 /etc/haproxy/errors/504.http

frontend ft\_rdp  
mode tcp  
bind \*:3389  
timeout client 1h  
log global  
option tcplog   
tcp-request inspect-delay 2s  
tcp-request content accept if RDP\_COOKIE   
default\_backend bk\_rdp

backend bk\_rdp  
mode tcp  
balance leastconn  
timeout server 1h  
timeout connect 20s  
log global  
option tcplog  
stick-table type string len 32 size 10k expire 8h  
stick on rdp\_cookie(mstshash)  
option tcp-check  
tcp-check connect port 3389  
default-server inter 3s rise 2 fall 3  
server RDSH1 172.29.101.1:3389 check port 3389  
server RDSH2 172.29.101.2:3389 check port 3389  
server RDHS3 172.29.101.3:3389 check port 3389  
#server RDSH4 172.29.101.4:3389 check port 3389  
server RDSH5 172.29.101.5:3389 check port 3389  
server RDSH6 172.29.101.6:3389 check port 3389  
server RDSH7 172.29.101.7:3389 check port 3389  
server RDSH8 172.29.101.8:3389 check port 3389

listen stats  
bind :9000  
mode http  
stats enable  
stats hide-version  
stats realm Haproxy\ Statistics  
stats uri /haproxy\_stats

---

<div class="post-metadata">

**Author:** ![ghp](https://avatars.discourse-cdn.com/v4/letter/g/ee59a6/32.png) [@ghp](https://discourse.haproxy.org/u/ghp)\
**Post date:** [May 4, 2018, 6:46am UTC](https://discourse.haproxy.org/t/haproxy-remote-desktop-services-2016-not-balancing/2454/4 "2018-05-04T06:46:08Z")

</div>

HAProxy 1.7 iso. 1.8 ?

---

<div class="post-metadata">

**Author:** ![pgodinic](https://avatars.discourse-cdn.com/v4/letter/p/90db22/32.png) [@pgodinic](https://discourse.haproxy.org/u/pgodinic)\
**Post date:** [February 1, 2020, 4:50pm UTC](https://discourse.haproxy.org/t/haproxy-remote-desktop-services-2016-not-balancing/2454/5 "2020-02-01T16:50:05Z")

</div>

How did you solve this?
