Nginx with Memcache Vs Varnish

memcachememcachednginxvarnish

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

Best Answer

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 ;)