Understanding huge RAM utilisation diff between 1.5.18 and 1.6.9


#1

I’d like to understanding and probably calculate/verify approx. how much memory haproxy should consume for serving certain no. of tcp connections (25% SSL). This interests me because when I upgraded haproxy from 1.5.18 to 1.6.9 I am seeing huge drop in memory utilisation (1.5.18 almost consuming 4x more RAM). Would like to understand whether it’s due to certain improvements/bug fixes (I’ve glanced through change log but didn’t noticed anything significant in this context or due to something which might be deteriorating my user’s experience here and I need to dig deeper?

Putting stats here from two servers (both are same r3.xlarge instance type in AWS serving same purpose):

Server 1 (haproxy 1.5.18):

root@ip-10-0-7-129:~# haproxy -v
HA-Proxy version 1.5.18 2016/05/10

root@ip-10-0-7-129:~# echo “show info” | socat stdio /var/run/haproxy.socket | egrep "CurrConns|CurrSslConns"
CurrConns: 171873
CurrSslConns: 26128

root@ip-10-0-7-129:~# free -g
total used free shared buffers cached
Mem: 29 12 17 0 0 0
-/+ buffers/cache: 11 18
Swap: 0 0 0

root@ip-10-0-7-129:~# ps -ef | grep [h]aproxy
haproxy 20869 1 45 Nov02 ? 21:07:14 /usr/local/sbin/haproxy -f /etc/haproxy/haproxy.cfg -D -p /var/run/haproxy.pid
root@ip-10-0-7-129:~#

Server 2 (haproxy 1.6.9):

root@ip-10-0-7-205:~# haproxy -v
HA-Proxy version 1.6.9 2016/08/30

root@ip-10-0-7-205:~# echo “show info” | socat stdio /var/run/haproxy.socket | egrep "CurrConns|CurrSslConns"
CurrConns: 172815
CurrSslConns: 26321

root@ip-10-0-7-205:~# free -g
total used free shared buffers cached
Mem: 29 3 26 0 0 0
-/+ buffers/cache: 3 26
Swap: 0 0 0

root@ip-10-0-7-205:~# ps -ef | grep [h]aproxy
haproxy 21785 1 50 Nov03 ? 13:55:30 /usr/local/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid -D -sf 28197
root@ip-10-0-7-205:~#

Instances are exactly same in terms of configurations/OS/kernel:

$ uname -a
Linux ip-10-0-7-205 3.19.0-69-generic #77~14.04.1-Ubuntu SMP Tue Aug 30 01:29:21 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Following haproxy compilation command is used for both versions:

make TARGET=linux2628 CPU=native USE_STATIC_PCRE=1 ADDLIB=-lz USE_OPENSSL=1 DLMALLOC_SRC=/home/ubuntu/malloc.c

Any insights will be highly appreciated. Thanks


#2

1.6 has dynamic buffer allocation, also see doc/design-thoughts/dynamic-buffers.txt.