Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't varnish taking into account the malloc limit?

Tags:

varnish

I have varnish running with -s malloc,25G, but the process keeps growing until it consumes all the server memory and it crashes, restarting the cache.

Any idea what I can check to see what's wrong?

The server has 16 cores, and 32 GB of RAM.
I am using varnish 3.

28346 ? Ss 0:16 /usr/sbin/varnishd -P /var/run/varnishd.pid -a :9290 -T localhost:6082 -f /etc/varnish/default.vcl -s malloc,25G -p thread_pools 16 -p thread_pool_min 160 -p thread_pool_max 16000 -p thread_pool_add_delay 2

Memory

Close up

like image 824
juan Avatar asked May 22 '13 13:05

juan


2 Answers

The -s malloc,25G only limits the cache size, not the size of the varnishd process.

It is important to keep in mind that the size you specify with the -s argument is the size for the actual cache. Varnish has an overhead on top of this for keeping track of the cache, so the actual memory footprint of Varnish will exceed what the ‘-s’ argument specifies if the cache is full. The current estimate (subject to change on individual Varnish-versions) is that about 1kB of overhead needed for each object. For 1 million objects, that means 1GB extra memory usage.

If you have a large cache, the file backend may be preferable.

like image 122
Joachim Isaksson Avatar answered Nov 09 '22 11:11

Joachim Isaksson


The documentation is correct, but problem is even worse due to memory fragmentation. To be on the safe side, you should allow for 1.5x to 2x the size configured for the malloc stevedore

like image 38
Nils Goroll Avatar answered Nov 09 '22 09:11

Nils Goroll