cachingredismemcachedvarnisheaccelerator

Stacking caching engines


I'm trying to understand a bit better the differences in caching engines, and which ones can be stacked with the other. Right now we have two webservers with a separate DB server. We're gonna be using Redis over TCP in order for both webservers to share the same cache. I'm interested in Varnish, or eAccelerator - as I understand eAccelerator is a php-caching engine, while Redis, similar to Memcached is a db caching - so those two should stack? And what about Varnish? Memcached and Redis are mutually exclusive as I understand.


Solution

  • Memcached and Redis are mutually exclusive as I understand.

    For the most part, yes. If your data set, however, exceeds what can normally fit into RAM (single node), memcached scales better than Redis since most memcached client libraries support consistent hashing that distribute data across a group of memcached nodes, so the aggregate total of RAM from all nodes becomes your total data set capacity; simply add more memcached nodes to increase capacity.

    You can shard (horizontally scale) with Redis to support a larger data set, but choices to do so are limited. Twitter developed twemproxy to shard redis keys across of group of redis nodes; while Redis Cluster is still a work in progress, twemproxy is the recommended approach to scale redis.

    So use one or the other; you don't need both, but in either case, the web/app server is typically the client to memcached/redis.

    I'm interested in Varnish, or eAccelerator - as I understand eAccelerator is a php-caching engine.

    Varnish is a reverse-caching proxy that resides in front of your app/web server. It caches entire rendered pages and greatly reduces load on your app server. It's usually the entry point (not counting load-balancers) in a typical web stack.

    I don't have experience with eAccelerator, but based on quick research, it's not mutually exclusive with Varnish. A typical stack may include varnish talking to PHP/eAccelerator or APC (check that out too). Also, you may want to consider adding nginx to the mix, see this.

    Hope that helps