Enabling redis on more than one site messes up the sites

Enabling redis on more than one site messes up the sites.

I’ve installed ee 3.3.1 on a fresh Debian 8.1 VPS. Next I’ve created 4 sites on that VPS:

ee site create mysite1.com --wpredis
ee site create mysite2.com --wpredis
ee site create mysite3.com --wpredis
ee site create mysite4.com --wpredis

Next I log in on all the 4 sites and I enable the “redis object cache” on the first site. As soon as I enable the “redis object cache” on the second site, I get logged of that second site and it is not available anymore. When going to ‘mysite2.com’ it redirects to ‘mysite1.com’. The same happens for the third and the fourth site as soon as I enable the “redis object cache”.

Note that I started from a fresh Debian 8.1 VPS.

This is a major issue with the redis cache.

IMO this is a bug, but I was asked to put it here and not on the github repo.

@ddelaey I ran into a similar problem after 3 different wordpress installations with --wpredis. The solution I found was adding the following to the wp-config.php in each one.

define( 'WP_CACHE_KEY_SALT', 'sitename:' );

replace ‘sitename’ with the domain if you like. It creates a different key for each wordpress instance.

Another option is to add this two lines, then each site can use a different database.

define('WP_REDIS_DATABASE', 1);
$redis_server = array( 'host' => '', 'port' => 6379, );

you can have up to 16 databases.

If you are using HHVM add to your hhvm-redis.conf this line:

fastcgi_param  HTTP_ACCEPT_ENCODING      "";

see here

Other thing you might want to consider is adding to your redis.conf, if using 64bit os.

maxmemory 350mb
maxmemory-policy volatile-lru

see Redis Documentation

hope this help…

You don’t need this constant set. Setting it means that you have a file named advanced-cache.php in wp-content, which in the case of wpredis, we don’t.

Some further info on this page.


Thanks for the info, updating my settings.

I had the same issue even before –wpredis option was implemented into EE. And I also fixed it by assigning different logical database for each website to use. But I find it strange to believe that EE team missed this. In their description of the new option they are saying they thoroughly tested it and are currently using this on many sites and servers, if it was an issue I’m sure they would have noticed that.

Can we get someone from EE development team to comment?

I thought it was a simple thing to just add some code that will generate a new number when new site is created for logical database not to conflict with other sites using REDIS, or as angelmartinez suggested a unique key for each domain/site.

Thank you.

There’s an option in Nginx-Helper plugin under Redis Settings to specify a Prefix like this:

PREFIX     nginx-cache:

I think this is the value that needs to be set individually for each site (e.g. change nginx-cache: to yourdomain.com:slight_smile: then Redis cache will have no issues described in the original topic/question. Is this correct?

It must be. If it was a special reserved value for Redis to work with Nginx-Helper plugin it wouldn’t be allowed to change its value in the settings. So as long as it remains unique for each site we don’t need to add anything to wp-config.php file.

This is my thinking but correct me if I’m wrong.

See also: https://wordpress.org/plugins/redis-cache/other_notes/

Thanks everyone for helping out on the issue :slight_smile:

Fix from EE is coming, see: https://github.com/rtCamp/easyengine/issues/593

So Nginx-Helper plugin, is not needed anymore if using Redis Cache?

Hello @RoldanLT

Nginx-Helper cleans nginx’s fastcgi/proxy cache or redis-cache whenever a post is edited/published. So you may need this even when you are using Redis Cache .

1 Like

Hello @ddelaey

With new release of EE 3.3.2 the following issue has been fixed. refer https://github.com/rtCamp/easyengine/releases/tag/v3.3.2

For already created sites please make changes in wp-config.php with

define( 'WP_CACHE_KEY_SALT', 'sitename:' );

@Prabuddha @harshadyeola

I’ve updated to V3.3.2 and I get following issue:

/home/david# ee -v
EasyEngine v3.3.2
Copyright (c) 2015 rtCamp Solutions Pvt. Ltd. 

/home/david# ee site create myothersite.com --wpredis
Redis is experimental feature and it may not work with all CSS/JS/Cache of your site.
You can disable it by changing cache later.
Do you wish to enable Redis now for myothersite.com?
Type "y" to continue [n]:y
Unable to Search string SCRIPT_FILENAME in /etc/nginx/fastcgi_params

What’s happening?

Update: the same happens for just --wp sites since the update:

/home/david# ee site create myothersite.com --wp
Unable to Search string SCRIPT_FILENAME in /etc/nginx/fastcgi_params

/etc/nginx/fastcgi_params does not even exist.

Kind regards, David

The fastcgi_params file was renamed to fastcgi_params.old, but no new fastcgi_params file was created. The nginx.conf file was renamed to nginx.conf.old, but no new nginx.conf file was created. The only thing I did was ee update and ee site create, nothing else.

Can this be an issue/bug in ee?

Copying the .old files to the original names fixes the issue.

What went wrong?

I can confirm that this exact thing happened to me also.

I’m happy it’s not me alone :slight_smile: :slight_smile: :slight_smile: @DaveNaylor can you comment this to https://github.com/rtCamp/easyengine/issues/593 too? So, the EE engineers know there really is an issue. Where you able to fix it the same way I did? Thanks, David.

@ddelaey Done! And yes, I fixed things in the way you did.

Then this should be automatically installed alongside with redis plugin when we created/update WP Redis.

@RoldanLT I think the nginx-helper plugin is always installed when you do a ee site create. Right @Prabuddha ?

Not on mine. When I update an old WP site previously using WP-Super-cache.