# High memory usage with many SSL certificates and slow (re)load

**URL:** <https://discourse.haproxy.org/t/high-memory-usage-with-many-ssl-certificates-and-slow-re-load/4686>\
**Category:** Help!\
**Created:** [January 2, 2020, 4:19pm UTC](https://discourse.haproxy.org/t/high-memory-usage-with-many-ssl-certificates-and-slow-re-load/4686 "2020-01-02T16:19:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jb-boin](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@Jb-boin](https://discourse.haproxy.org/u/Jb-boin)\
**Post date:** [January 2, 2020, 4:19pm UTC](https://discourse.haproxy.org/t/high-memory-usage-with-many-ssl-certificates-and-slow-re-load/4686/1 "2020-01-02T16:19:15Z")

</div>

On 2.0.12 servers with around 18000 RSA SSL certificates (mainly LetsEncrypt certs) loaded with crt-list, each HAProxy worker threads uses around 10Gb or RAM (only 200Mb if the crt-list file is empty) and the reload time of HAProxy is of about 4 to 5 minutes on a server with a Xeon E3-1241 v3 with 32Gb of RAM and the certificates on a tmpfs partition.

Is there any way to optimize the memory usage and/or reload time?

The relevant configuration parts are (there are about 35 identical “bind” entries with different IPs)) :

> global  
> tune.ssl.default-dh-param 2048  
> ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets  
> ssl-default-bind-ciphers AES128+EECDH:AES128+EDH  
> tune.ssl.ssl-ctx-cache-size 4000  
> nbproc 1  
> nbthread 7  
> cpu-map auto:1/all 0-
> 
> frontend frontend-ssl  
> bind $IP:443 ssl crt /path/wildcard.defaultdomain.com.pem crt /path/wildcard.otherdomain.com.pem crt-list /path/ssl-tmpfs/crt.list alpn http/1.1

---

<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 2, 2020, 5:06pm UTC](https://discourse.haproxy.org/t/high-memory-usage-with-many-ssl-certificates-and-slow-re-load/4686/2 "2020-01-02T17:06:06Z")

</div>

> [@Jb-boin](#):
>
> each HAProxy worker threads uses around 10Gb or RAM

I assume you mean worker process, otherwise you’d by using 70 Gb of RAM with the 7 threads you are using.

> [@Jb-boin](#):
>
> The relevant configuration parts are (there are about 35 identical “bind” entries with different IPs)) :

Identical as in the same certificates/certificate-list are used for all of those?

Then I’d suggest to unify them using a single bind statement instead, that should improve the situation by a factor of 35.

I believe 2.2-dev can do some deduplication here, but I’m not sure if it covers all cases and if it also improves reload time (or just memory consumption).

---

<div class="post-metadata">

**Author:** ![Jb-boin](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@Jb-boin](https://discourse.haproxy.org/u/Jb-boin)\
**Post date:** [January 2, 2020, 5:55pm UTC](https://discourse.haproxy.org/t/high-memory-usage-with-many-ssl-certificates-and-slow-re-load/4686/3 "2020-01-02T17:55:59Z")

</div>

Yes i was talking about worker processes and not threads.

And indeed the multiple IPs on a single “bind” statement did the trick, it now uses around 850Mb of RAM and takes only ~15seconds to reload, thanks for the trick.

A deduplication would be nice as it is loading the same file for multiple crt-list statements and the crt-list is still used twice as its also used on another frontend (but its now less of an issue in my case).

Thanks for the solution 🙂
