Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Other than virtual memory, How about RAM usage for Varnish?

Is it much RAM needed?

share|improve this question

You can run Varnish in a few different modes. One uses the disk as the cache repository and in this mode, you can safely restart Varnish without losing your cache. This also means you can support a very large cache and let the OS's IO cache keep the most requested content in the server's memory. This mode is configured with the flag -s file,/var/lib/varnish/varnish_storage.bin,1G

The other mode is memory-only - Varnish keeps all cached data only in memory, never writing to disk. This can deliver extremely fast response times, but the cache size is limited to how much memory your server has. Also, if you restart Varnish you lose the cache and suddenly requests will start flooding your backend. Note, however, that Varnish is extremely stable and we only ever restart Varnish when an update is released (every 6 months or so). This mode is configured like -s malloc,3200M

So to answer your question, Varnish performs much better with more RAM. We have a Amazon EC2 instance with 3.5GB RAM and no swap and give Varnish 3GB of RAM for caching. Currently we have almost the entire backend site in cache, including images and PDF files etc. I can definitely recommend this setup.

share|improve this answer

Which redirects you to here:

share|improve this answer
+1 for link to interesting article – sumar Mar 2 '10 at 21:43

Caches obviously thrive on memory. But how much you need depends on your site.

Benchmark varnish+your site using request logs, and see how fast memory use grows. Use a vm to test how many requests you can handle with different ram configurations (enable a ram balloon driver).

share|improve this answer

Varnish actually supports multiple storage backends. You can cache something to RAM, whereas something to disk:

-s default=malloc,256m \
-s static=file,/var/lib/varnish/varnish_storage.bin,1G"

This is most useful to conditionally store static files cache (.css, .js files) to disk, and storing full page cache into RAM. You will need to adjust your .vcl file appropriately to cache conditionally into each storage backend:

This will allow you to keep memory footprint at minimum, whereas still using part of RAM for cache.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.