nginx with Memcache Vs Varnish

12,981

IMHO this is not a question of "memcache vs varnish", but "varnish with or without memcache", and I think you should by all means use memcache whenever you can. In fact, memcache/memcached cahes data and objects from a database, whilst Varnish is an HTTP accelerator for "content-heavy dynamic websites".

Both work together really well, and for example a LEMP (or LNMP) platform with PHP-FPM, Varnish and memcached to host blogs and CMS (I use that config for my WordPress sites) is absolutely fantastic. In the case of WordPress, the help of plugins like W3 Total Cache that manage Varnish and memcached for different aspects of the caching makes everything transparent, and the performance is gorgeous.

So don't worry about installing it: just do it and enjoy the benefits ;)

Share:
12,981

Related videos on Youtube

Ilie
Author by

Ilie

Updated on September 18, 2022

Comments

  • Ilie
    Ilie almost 2 years

    I was wondering if anyone has any comments / benchmarks / suggestions on Varnish Vs Memcache when used to serve content (usually 2-5kb JS file depending on the parameters in request; thousands of diff files are possible)

    Currently we are using nginx + Varnish + LAMP to do this.

    I was reading about memcached module of nginx and was wondering if anyone has any benchmarks for caching content in Memcache and serving them directly from nginx (or pulling from LAMP incase of a miss), rather then passing the request to Varnish and letting it do the same job.

    Overall, is there any benchmark on setting and getting (as well as occassional purging) of content (usually 2-5kb) with Memcache Vs Varnish

    Thanks

  • Ilie
    Ilie over 12 years
    We already use memcache massively and have 5 dedicated servers for memcaching with abour 20GB cache available. Memcache is giving us a good layer of cache before we reach the databases. My Concern is that since our response size is also small (less than 5 kbs always, average being 1kb), I can save the whole in memcache and then can eliminate the need of Varnish.
  • javipas
    javipas over 12 years
    Oh, I see. You want to kill one of the "intermediate layers", right? I think both are useful for different things, and I'm not sure getting rid of Varnish would improve your performance. Your document size is pretty low, yes, but even then caching will always help, won't it?
  • javipas
    javipas over 12 years
    Understood. I guess your best bet is to test and try both configurations to see wich one really performs better. Good luck with it!
  • Nishanth
    Nishanth about 9 years
    The fastest IMHO is when you place Varnish' cache file on a ramdisk.