Varnish cache on small linode - file or memory?

I've setup a Varnish cache on a 512MB linode, using a 1GB file cache.

However, I've seen quite a lot of recommendations to make this a memory cache.

Thing is, I believe Linux will start caching the blocks from the varnish log file in memory, and thus don't see why this should make a difference (except for after restarting the machine)?

5 Replies

I'm going to be a dick and say "try it and see!" :-)

I haven't used it yet, but this blog post made me aware of something called vmtouch, which allows you to see (and control) what's in your cache. This can probably help answer that question.

And, of course, the standard admonition applies: If you aren't using munin or something similar to monitor memory usage, disk I/O, varnish stats, and page load times, you should install that and get it going before you even think of doing anything else. Web servers/applications/caches form a very complex system. Do you know if varnish is helping at all, or if you are even using 1 GB of it? ;-)

Hi Hooypcat

Thanks for the response - seems entirely reaonable to me! Thinking about it more than a few seconds (and not just lazily asking here!), I really don't need 1GB. I just have a few Drupal 7 sites (page size according to Chrome averages only ~100kb, but the vast majority of that is css, js, and jpeg, shared on all pages), with low traffic. My only reason for Varnish was to attempt to prevent any downtime should I be lucky enough for one of my posts to be linked from a high traffic site. I since also tweaked the Apache max clients down, so at least the whole node doesn't blow up either.

Thanks also for both those links - I seem to recall reading the Instagram one a while back, but had since forgotten about it. With that in mind might go the whole nginx route, and drop Varnish altogether.

Re Munin - I thought that's what generates the graphs on the Linode panel? Is there something extra I'd gain by setting it up myself?

Ok, my own empirical evidence on Varnish (on a 512MB linode) regarding cache settings in memory vs file, both 256MB:

None at all :)

Also investigated Varnish vs nginx:

b -c400 -n20000 http://mytesturl/

Varnish: 2200 req/sec, 35% CPU, 17% mem

nginx: 1900 req/sec, 26% CPIU, 0.2% mem

So Varnish uses more memory, and more CPU cycles… but I like the configurability/power of using VCL for stripping cookies, and the varnishlog/varnishtop etc utils.

Linode's graphs give you CPU, memory, and disk I/O. With munin, however, you can graph pretty much anything. This is perhaps a ludicrous collection of examples, but at a glance, I can tell you my memcached ain't doin' nothin' right now:

~~![](<URL url=)https://munin.sodtech.net/cdknnjln/fram … ry-day.png">https://munin.sodtech.net/cdknnjln/framboise/memcached_memory-day.png" />

(I can also tell you 42 customers are without power in my area, and that it's probably not snowing outside, but those are in the "ludicrous" category.)~~

Varnish is meant to use all RAM in a box and let the OS's virtual memory manager determine what gets cached and not. It also uses compression by default, if I'm not mistaken, which nginx may not, which could account for the higher CPU usage.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct