Linode Forum Index Linode Forum
Linode Community Forums
 


Varnish cache on small linode - file or memory?

Click here to go to the original topic

 
       Linode Forum Index -> Performance and Tuning
Author Message
marcosscriven



Joined: 17 Mar 2010
Posts: 8

Posted: Thu Dec 22, 2011 6:54 am    Post subject: 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)?
Back to top  
hoopycat



Joined: 30 Aug 2008
Posts: 1294
Location: Rochester, New York

Posted: Thu Dec 22, 2011 11:59 am    Post subject:  

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? ;-)
Back to top  
marcosscriven



Joined: 17 Mar 2010
Posts: 8

Posted: Fri Dec 23, 2011 3:47 am    Post subject:  

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?
Back to top  
marcosscriven



Joined: 17 Mar 2010
Posts: 8

Posted: Fri Dec 23, 2011 7:07 am    Post subject:  

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.
Back to top  
hoopycat



Joined: 30 Aug 2008
Posts: 1294
Location: Rochester, New York

Posted: Fri Dec 23, 2011 8:33 am    Post subject:  

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:



(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.)
Back to top  
Guspaz



Joined: 26 May 2009
Posts: 1150
Location: Montreal, QC

Posted: Fri Dec 23, 2011 10:36 am    Post subject:  

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.
Back to top  
 
       Linode Forum Index -> Performance and Tuning
Page 1 of 1