-1

I have a rather 'dumb' question regarding Varnish. I've been reading info on Varnish cache storage types and yet don't understand what would happen in following:

Imagine we have 2GB of free memory.

Varnish (with file storage) takes up 1,5GB

Then a process shows up which needs 600MB.

What will happen? Will Varnish reduce it's memory usage (and store remainder on disk) or what?

1 Answer 1

0

Varnish won't reduce the amount of memory allocated to it - but this is virtual memory. How this is treated will vary depending on the OS and how it's configured.

In your example, assuming it were running on Linux, then it will depend on how much physical memory (RAM and swap) is allocated (which will be less than or equal to the amount of virtual memory allocated. Since applications often ask for more memory than they need, the default configuration on mst distributions is to overcomit the memory by 50%. If the overcommit allows the second application to allocate the memory, then it will start up. When the physical memory usage goes over some threshold, the OOM killer will kick in a start terminating process. If the 600Mb exceeds the amount of physical memory + memory from overcommit then the malloc call should fail - at this point the new application should handle the situation gracefully.

2
  • Okay, so you mean to say that the new application wouldn't start at all? Also, consider a more real life situation where there are already webserver's processes present - would Varnish then resume cache saving on HDD? THis is more Varnish (and it's file storage option) related question, than general question regarding memory management between applications. Thanks! Jun 28, 2013 at 14:47
  • Varnish uses the cache you have configured it to use. It will not respond to a low-memory condition by switching to a disk-backed cache. It does not monitor, at any level, whether you are running out of RAM. It concerns itself solely with itself. To emphasize: it will happily allocate more RAM to store the unlikeliest result in its LRU list, at the expense of causing the OOM killer to kick in and kill mysqld. It simply doesn't know or care. It uses what you've told it to use.
    – BMDan
    Jul 5, 2013 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .