Site: US UK AU |
Nexcess Blog

Redis In-Memory Caching Substantially Improves Magento eCommerce Performance

November 13, 2014 11 Comments RSS Feed

Redis In-Memory CachingWe all know that when it comes to eCommerce, faster is better. Slow web pages cause billions of dollars in lost eCommerce revenue every year. A third of eCommerce shoppers will turn to a competitor if a store provides a poor user experience because of latency. And 44 percent of users assume that a slow shopping cart means that their transaction has failed. Nexcess understands eCommerce retailers’ need for fast, consistent, and stable performance, which is why we base our performance optimized eCommerce hosting plans on Magento.

But however fast the eCommerce platform and servers and however optimized the PHP execution and database environment, there’s a limit to what can be done without caching, which is why many of our Magento plans use caching applications that include Memcached, Redis, and Varnish.

Memcached is an excellent caching solution, particularly because it is a multi-threaded caching system that can take advantage of multiple cores. But Memcached also has some limitations that prevent it from being the ideal solution in some scenarios.

Redis is a key-value store that works brilliantly with Magento, offering better performance than Memcached alone in many situations and with additional functionality that makes it a compelling option.

Just like Memcached, Redis an in-memory key-value store that can cache Magento data and serve it significantly more quickly than Magento itself, which relies on database queries and disk reads, but Redis has a number of advantages over Memcached, which include:

  • Persistence — Memory is volatile and if a server goes down, the data cached in memory is lost. Redis is capable of snapshotting its dataset to disk at intervals, ensuring that at most a few seconds of data is lost.
  • Replication — Redis supports master-slave replication — data can be duplicated across a number of slave nodes — which makes it easy to scale Redis and avoid the single point of failure introduced by having a non-replicated cache.
  • Rich data types — Redis has a much richer set of data types than Memcached, one significant advantage of which is that it allows us to tag sets of values as related, which can greatly increase the efficiency of flush operations for applications like Magento.

However, unlike Memcached, Redis is a single-threaded application, which means that it can only process requests one at a time.

Try it yourself

At Nexcess, we understand that a one-size-fits-all approach doesn’t always result in the optimal solution, which is why we offer a variety of caching strategies using both Redis and Memcached. Magento Enterprise Edition eCommerce hosting clients can choose to use either key-value store in a variety of configurations for backend and session caching, or even both in a split-backend cache configuration. We are happy to work with clients to accommodate their specific requirements.

In concert with our other optimizations, exhaustive testing showed that by coupling Magento with Redis and Memcached, we were able to achieve massive performance increases for Magento eCommerce stores.

If you’d like more information about our performance optimized Magento hosting, don’t hesitate to get in touch.

Posted in: Magento
  • can it be used with varnish?

  • Varnish has its own internal memory based storage cache, so using redis with varnish would not be necessary.

  • I really like and appreciate your blog post.Really looking forward to read more.

  • Riyaz

    Can I use it with Lesti FPC?

  • Riyaz

    Ben, I know about the plugin and I am using it. Will you configure Lesti FPC with Refis if i buy your SIP 200?

  • It would be beneficial to the community if you could post a write up on your blog on how to configure Lesti FPC with Redis on your SIP?

  • Gary Mort

    Note: when using Redis make sure to install the PHP Redis Extension. While it is technically correct that you ‘do not need the extension’ to use Redis from PHP – in practice I have never found this to be true. To use Redis without the extension, the code uses PHP Streams/Sockets. While technically you can do this – you could also use Streams/Sockets for Mysql and Memcache. Unless an application is specifically written not to use an extension, the Streams/Socket implementation will be extremely problematic. PHP Streams default settings are not designed for robust error handling/recovery. By default, they have a 60 second timeout, so if there are any issues with the caching connection the web page generation can slow down to over a minute. With caching, you want a quick go/nogo – under 50ms. If you can’t get a cache value in under 50ms, then it’s a waste of time to wait for it longer – it’s faster to generate everything fresh.

    Not only is there a 60 second timeout, it is not intuitive that there are a number of different timeouts which all have to be adjusted. There is the initial connection timeout. After the initial connection, for every request to retrieve another cache value there is a timeout. While most people catch the initial timeout issue[I think the Magento redis module defaults to using 2.5 seconds, which is still way too high but at least it is not 60 seconds] – but it fails to set the ongoing timeout, sticking you right back at 60 seconds.

    All this amounts to a simple plea, use the PHP Redis Extension:

    It doesn’t do anything that can’t be done with pure PHP – however my experience is that Stream/Socket code written in PHP ends up missing key socket parameters that results in code which works and passes unit tests, but falls down when run in the real world instead of on an ideal test server.

    Extensions written in C don’t have the luxury of relying on default settings as much, so having to write the extension tends to result in tighter, better code.

  • John Williamson

    Do I need to edit my Magento installation files at all to enable/configure Redis or Memcached?

  • Can I use it with Lesti FPC? tell me…..

  • can it be used with varnish? tell me