cancel
Showing results for 
Search instead for 
Did you mean: 

Redis vs Memcached, which does Magento recommend?

SOLVED

Re: Redis vs Memcached, which does Magento recommend?

It is precisely because of the built in support for Redis that I would recommend Memcache over Redis.

 

Unfortunately, the built in support for redis will try to use the PHP redis extension, but if it does not exist it falls back to using pure PHP code.   Pure PHP code is not something you should use to increase performance!   The defaults used by PHP for network operations are the same defaults used by the underlying C code.  Those defaults are not optimized for performance, but rather for fault tolerance.   This results in weird, random seeming delays when trying to check to see if something even exists in the cache.

 

You could use pure PHP code to connect to MySQL also!  There is a reason good PHP applications do not do this - or at least force you to be very very explicit if you choose to do something like this.

 

That said, Redis and Memcache are generally bad choices for caching for most Magento websites.  What caching mechanism to use depends strongly on at what growth point you are at.  From smallest to largest:

  1. Shared server: your website is on a single server which hosts many different websites
  2. Dedicated Server: your website is on a single server which may host a few other websites of yours and the database server runs on the same system as the web server
  3.  Dual Servers: your website resides on a single server and your database resides on a separate server
  4. Dual front-ends: your website is run from two servers
  5. Locally Clustered front ends: your website resides on many servers all in the same data center
  6. Dispersed Clustered front ends: your website resides on many servers that are distributed onto different network access points[geographically or otherwise]

 

It is only when you reach stage 5 that you should be considering a dedicated caching server - and at that point Memcache is the clear winner.  Redis may or may not be faster, but Memcache is time proven and you don't want to experiment with your livelyhood.  Where memcache falls down is when you need multiple caching servers.  This only occurs at stage 6 - at which point you can consider redis.

 

So what do you use before stage 5?

Almost always, the best solution to balance performance, configuration, and troubleshooting is to use file system caching.  A file is easy to understand, it is easy to troubleshoot, and it is just as fast as an in memory caching system,  That is because your operating system can dedicate a chunk of memory and use it as a file system - in fact it likely already does this with the /tmp folder.

 

It is much easier to add a single line to your servers fstab file and dedicate a fixed size slab of memory for caching.

 

At some point during stage 4, there are some better performance options over tmpfs - but not memcache or redis.