easyengine icon indicating copy to clipboard operation
easyengine copied to clipboard

[Poll] Redis v/s Memcache for WordPress Object Cache

Open rahul286 opened this issue 11 years ago • 21 comments

Hello Everyone,

We are planning to stop using W3 Total Cache for wordpress object-cache soon. W3 Total Cache is a good plugin but all we will be needing is object-cache.php going ahead.

So I want to know if anyone is using WordPress object cache directly with redis or memcache?

I tried few plugins and come across some more... Below are my observations:

Memcache plugins

  1. https://wordpress.org/plugins/batcache/ (outdated, also has more features)
  2. https://wordpress.org/plugins/memcached/ (outdated)
  3. https://github.com/tollmanz/wordpress-pecl-memcached-object-cache (tried, but it crashed. Will try again)

Redis

  1. https://wordpress.org/plugins/wp-redis/ (did not try but seems biased towards Pantheon hosting comapny)
  2. https://github.com/BenjaminAdams/wp-redis-cache (does more than what we need)
  3. https://github.com/ericmann/Redis-Object-Cache/blob/master/object-cache.php (did not work, will try again)

Basically, I think we just need an object-cache.php file. EE can place fine in right place and add define('WP_CACHE', true); line to wp-config.php.

So please share your object-cache.php and your views.

A note about redis

Redis has 2 PHP libraries - one is Predis (made in PHP) and other one is PECL extension (made in C). I think we should be going with library made in C. EE can install all required dependencies.

rahul286 avatar Mar 20 '15 15:03 rahul286

Did you tried https://wordpress.org/plugins/redis-cache/ ? Seems very good !

thedevly avatar Mar 23 '15 21:03 thedevly

From what I've read about how Pinterest scaled their service as it grew by leaps and bounds, they stuck with a combination of memcache AND redis - and they recommend it for feeds as a key point of what they learned at the end of this presentation: http://www.percona.com/live/mysql-conference-2012/sessions/scaling-pinterest

If we were able to choose one or the other at site creation, you could easily define our choices as "memcached: general purpose sites, easy configuration, very stable" and "redis: high traffic, big data sites, advanced configuration, monitoring suggested". The article "Memcached vs Redis?" lays this out pretty well: http://www.bigdatalittlegeek.com/blog/2014/3/25/memcached-vs-redis.

That said, is it possible for us to choose from one or both methods at site creation?

On Mon, Mar 23, 2015 at 4:56 PM, doringheorghe [email protected] wrote:

Did you tried https://wordpress.org/plugins/redis-cache/ ? Seems very good !

— Reply to this email directly or view it on GitHub https://github.com/rtCamp/easyengine/issues/472#issuecomment-85219951.

MattyLB avatar Mar 24 '15 02:03 MattyLB

@MattyLB as far as wordpress-object-cache is concerned, we need to choose either memcache OR redis. Same is the case with PHP sessions storage I believe.

IMHO it's better NOT to have too many trivial choices. Lets do some reading, tests and choose one. If we realise we made a wrong choice, we will switch to other alternative.

rahul286 avatar Mar 24 '15 04:03 rahul286

@rahul286 I have been trying EE (which is awesome) and after a bit of research I have decided move away from W3TC because all I need is object caching. Right now I have memcached. If you have identified a way to do this it would be great if you could share it with us.

SimpleHomelab avatar Apr 14 '15 15:04 SimpleHomelab

Agreed - EE is incredible. Same here, I need to migrate away from W3tc. I have a site which is starting to die, super long page load times (ttfb), part of the problem is the complex theme which makes WP work too hard. I'd like to be able to simplify without this plugin, and would be great if the object cache allowed me to speed up the experience for logged in user as well. I am running pagespeed on top of W3tc and the primed/logged out experience is acceptable, logged in experience is dismal. I'd be willing to try anything out.

cm896 avatar Apr 14 '15 15:04 cm896

@cm896 we are also already trying to move away from w3tc.

You can try redis-cache as suggested here - https://github.com/rtCamp/easyengine/issues/351#issuecomment-89757412

I am currently testing it on rtcamp.com

rahul286 avatar Apr 15 '15 09:04 rahul286

@rahul286 - I have disabled w3tc and installed redis per the rtcamp threads. Redis is working, the monitor shows tons of activity, but my site is still very slow to kick out that first byte. I really love the admin tools redis browser, that's nice.

I think once the page cache was disabled in w3tc I noticed the performance hit immediately. I am wondering if I should disable this include in the nginx conf for this site: include common/w3tc.conf;

and use another include, like the wpfc.conf instead?

cm896 avatar Apr 15 '15 16:04 cm896

@cm896 If you are not using w3tc I think you remove that include. If you are using NginX fastcgi cache then wpfc.conf should be included. @rahul286 or others can correct me.

I am yet to try Redis.

SimpleHomelab avatar Apr 15 '15 16:04 SimpleHomelab

I had disabled the w3tc config and have been using the wpfc config. I thought the object cache would help alleviate some of the speed issues for the ttfb. It hasn't. :( I have been debugging the action logs and noticed a huge amount of time to build the header nav, some 20k actions of the 62k actions to build the home page. :( bad theme, bad theme.

cm896 avatar Apr 15 '15 16:04 cm896

Yes - I had removed w3tc config and placed wpfc in it's place. My logs are showing HIT, MISS and BYPASS, but with horrible timings. Misses in the range of 5 - 10 seconds, etc...

cm896 avatar Apr 15 '15 16:04 cm896

Overall the redis change is holding up and is performing well, but only a minor improvement over the memcached solution. I like the redis tools and browser better. :)

However in my continued effort to remove the caching plugin/function from WP, I am going to be running a few tests with a modified ee 3.1.0 setup plus components as outlined here: http://wptavern.com/speed-up-your-wordpress-site-with-pound-varnish-nginx-and-mod_pagespeed

My client is running an https only WP site. It performs fairly well when a user is not logged in. The article mentions how the varnish cache will be passed with logged in users, but I will compare the results to what my client has now, in their current setup. Current: WP, nginx -wpfc, spdy & pagespeed (still using memcached), redis

Testing: WP, nginx -wp, spdy, pagespeed, hhvm, varnish+pound, (possibly redis/memcache)

I think there might be a benefit with adding pound as a decelerator and possible load distributor and having the varnish (reverse proxy) before nginx might speed things up. I'll use the new ee 3 with the hhvm and fall back to php-fpm.

Links: http://www.apsis.ch/pound https://www.varnish-cache.org/docs/4.0/

cm896 avatar Apr 16 '15 14:04 cm896

@cm896 please check ee debug tools. If site is slow for logged in users, it may mean bad php code and/or slow sql queries are there.

You may check my slides at a recent WordCamp - https://rtcamp.com/slides/easyengine/wc-mumbai-2015/?full#cover

rahul286 avatar Apr 16 '15 14:04 rahul286

I know this does not answer Memcached vs Redis. But I did a Blitz comparison of with and without EE. Noticed that with EE and Nginx fastcgi I am getting a lot of timeouts on the same site. https://github.com/rtCamp/easyengine/issues/497

SimpleHomelab avatar Apr 16 '15 19:04 SimpleHomelab

@rahul286 - yes, I need to setup debug and find the cause of this site's problems.

@htpcBeginner I love the comparison.

cm896 avatar Apr 16 '15 19:04 cm896

@rahul286 I notice now that when --wpredis flag is used, redis full page cache and redis object cache with the redis-cache plugin are used... great!

It think it would be even greater and make sense if the -wpfc nginx battle tested full page cache option got rid of w3 total cache completely and also used redis object cache with the light weight well maintained redis-cache plugin (perhaps it could be forked and merged into the nginx helper plugin? easyengine helper maybe ;) ).

This way people who still want to use w3 total cache (and memcached) for whatever reason can just use the --w3tc option.

kymcarlsson avatar Feb 14 '16 12:02 kymcarlsson

Can another Poll be conducted regarding automated integration of WordFence security with their Falcon Engine enabled and configured not to cache account and ecommerce pages?

I've noticed significant performance increases with Falcon Engine in the past, though I always seemed to run into cart caching issues because I didn't know how to keep certain pages from being cached, especially with SSL caching enabled. My suspicion is that there were conflicting rewrite rules between EE's nginx rewrites and the falcon engine rewrites.

Either way, it would be nice to have a security option that is fully compatible with EE's nginx config that can be installed via the command line. eg...

--wordfence (installed & configured w/o falcon engine) --wordfence=falcon (installed w/ falcon engine enabled) --wordfence=off (removes wordfence app & configs)

Thanks and keep up the great work with EE!

MattyLB avatar Feb 15 '16 05:02 MattyLB

https://wordpress.org/plugins/memcached/ is no more "outdated": is 6 days old as I'm writing this.

pkirk avatar Mar 23 '16 13:03 pkirk

Requires: 3.0 or higher Compatible up to: 4.5 Last Updated: 6 days ago Active Installs: Less than 10

It's so advanced it's even caching it's own active installs count!

In all seriousness though, I only want nginx page caching and an object cache and not w3-total-cache so I'm going to give https://wordpress.org/plugins/memcached/ a go..

I'm guessing what's beneath would just work as memcached is inplace due to --wpfc?

ee site create example.com --wpfc
wp plugin uninstall w3-total-cache
wp plugin install memcached --activate

Actually, while we're on it @rahul286 - is memcache in place with site create --wp ?

kymcarlsson avatar Mar 23 '16 14:03 kymcarlsson

Hi @kymcarlsson what are your experiences with the WordPress Memcached plugin so far? I'm running a few multisites where I replaced W3TC with the Memcached plugin but I have had issues on one installation where MarketPress is running and Product attributes (like price etc) could not be updated anymore. I suspect it has to do with the expiration of cached objects. With W3TC that was set to 3 minutes while the Memcached plugin does not bother with expiration at all. I wonder what's the best/safest policy... I'm sure "it depends!" applies here ;)

RavanH avatar Apr 04 '16 14:04 RavanH

@rahul286 - Memcache or Redis, which do you advise or prefer? Are there big differences in performance, resource usage and/or easy of configuration and maintenance?

RavanH avatar Apr 04 '16 15:04 RavanH