5

I'm wondering what kind of performance increase, and in what situations, I might expect from using Redis or Memcache over the default file-based caching.

I know template caching always comes from the DB, so I'm not sure what else I can expect to be cached from Craft itself, and how that might impact site performance.

4 Answers 4

3

As with most performance related questions, the answer is "it depends". :)

Apps like Redis and Memcache store their key => value stores in memory as opposed to disk-based file caching.

Accessing data from memory is usually orders of magnitude faster than accessing data from disk.

All of these fall under "General purpose data caching" and Craft will use them internally for its own operations and plugins can certainly make use of them as well.

If you have a plugin that makes extensive use of data caching and/or you've got a heavily trafficked site, then you will likely see some tangible performance benefits.

If you're just doing a basic stock Craft install on a low trafficked site, then you likely won't see much of a difference at all.

3

How many servers do you have?

Redis and Memcached are most beneficial/intended for a multiple server setup so if you only have one server, there's probably other/betters thing to worry about. (Best speed increase I've found so far: PHP 7.)

As Brad points out, it all depends on your content, traffic, concurrent users, etc.

It goes without saying having enough ram so you're not swapping can have a huge benefit. Just because those files are stored on disk doesn't mean PHP itself is actually hitting the disk for each request.

SSDs are also now coming standard with a lot of the better hosting plans. SSDs can rival in-memory access times. Just changing your hosting can have a big impact on your app's performance.

If you go down the deamon route, Redis seems more modern and is the newest contender in this space. I haven't extensively used Redis or memached with Craft but I have a client with WP on a dedicated server. We tried memcached awhile back and it was actually slower than without it. It's not hard to see why: there's going to be overhead reading/writing to either daemon—after all they communicate via socket or TCP/IP—and whether that solves your particular performance problem is up for debate.

memcached hasn't really evolved much as of late. While memcached is strictly a key/value store, Redis is intended to store object structures better.

tmpfs could be an alternative as well. It's basically a ram disk and is built into most Linux distros. It's pretty easy to setup and like everything else it has some caveats (making sure it comes back up on reboot, having enough space so you don't swap to begin with, clearing etc).

Some further reading:

1
  • Right - if we go with Redis, it'll be on its own VPS.
    – Tim Kelty
    May 16, 2016 at 19:10
2

Here you can find an interesting benchmarking between Redis (remote or local) and Python Disk caching. The answer from Didier Spezia is good enough to understand the results. https://stackoverflow.com/a/12871072/8520235

Enough RAM and disk caching are always better solutions for reasonable amounts of data. Any local, not to say remote, Redis solution includes network roundtrips, that these days are slower than Linux disk caching or even SSD disk access.

1

Redis and Memcache are both Key value pair storage, their key => value stores in memory as opposed to disk-based file caching that make is faster to access compare with accessing data from disk

Few Interesting properties of Redis:

  1. Redis can be accessed by all the processes of your applications, possibly running on several nodes (something local memory cannot achieve).

  2. Redis memory storage is quite efficient, and done in a separate process. If the application runs on a platform whose memory is garbage collected (node.js, java, etc ...), it allows handling a much bigger memory cache/store. In practice, very large heaps do not perform well with garbage collected languages.

  3. Redis can persist the data on disk if needed.

  4. Redis is a bit more than a simple cache: it provides various data structures, various item eviction policies, blocking queues, pub/sub, atomicity, Lua scripting, etc ...

  5. Redis can replicate its activity with a master/slave mechanism in order to implement high-availability.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.