8

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

juan
  • 80,295
  • 52
  • 162
  • 195

3 Answers3

11

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.

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
1

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

Nils Goroll
  • 148
  • 4
0

Varnish might use the double of the given value because of fragmentation. You can read more here: https://info.varnish-software.com/blog/understanding-varnish-cache-memory-usage

By the way: Varnish 3 has a security leak and is pretty old. Please update

france1
  • 141
  • 2
  • 12
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 22 '21 at 18:27
  • nono, bot, then the guide is there - better read it! – france1 Oct 22 '21 at 18:28