In my experience, communication with Redis is significantly faster when Redis is on the same machine as PHP. When distributing web traffic across several servers, I've found that it is useful to run Redis in a master-slave configuration, with a slave instance on each application server. Writes are always done on the master instance. Having a slave that is on the same server as PHP for reads offers greater performance.

I'll create a patch soon for this functionality. The approach is to:

  • Allow slave servers to be specified in settings.php
  • If any slave server(s) are defined, query from the slaves in cache_get and cache_get_multiple.

Comments

pounard’s picture

@jtsnow Good idea, hope you will provide a quality patch ^^ Remember that those modifications must not be too invasive, we need to be able to port, read and maintain code easily. Thanks again.

iler’s picture

@jtsnow Any progress on this one?

npscode’s picture

Hi jtsnow,

I am also looking for this. I want to read my data from redis slaves.

Let me know if you are working on this or any patch available.

Thanks..
Naren..

jtsnow’s picture

I did have slave reads working in a Drupal 6 implementation. I have not yet ported that to this module.

bibo’s picture

I'm very much looking forward to this functionality.

We have a setup with up to 30 (8core/16Gb) web-servers running Drupal in a cloud, but usually only about 5-10 webservers are online at a time. A single Redis-server wouldn't exactly scale with more webservers.

Could the patch make is possible to keep like.. uhm.. theorectically 30 Redis slaves for that one master? And what would happen if half of those servers are usually down, but could go online at any time?

pounard’s picture

I need to do this. Any patch are welcome.

pounard’s picture

Back to this issue. I'm going to try an implementation on the driver that allows this the easiest way. I'm leaning toward Predis, going to read its documentation right now!

@jtsnow What driver are you using, PhpRedis or Predis?

pounard’s picture

@#5 Being able to do dynamically failover on 30 servers seems a complicated thing to do at the PHP level: this would cost a lot of CPU time and block PHP processes while they're trying to reach an available server. I think you should try to find a proxy middleware that does the Redis load balancing for you, see:

I might try to implement slave read, but I don't think implementing a complex failover sounds like a good idea.

pounard’s picture

Also forgotten this one http://redis.io/topics/cluster-spec

iler’s picture

@pounard surely this will be implemented for both drivers, PhpRedis and Predis? Predis might be easier to setup but PhpRedis is more actively maintained and as a compiled PHP extension it is also faster.

iler’s picture

pounard’s picture

Somebody already posted an almost identical patch somewhere in the issue queue, I think I'm going to try to see if this is easy to implement over this module. If this cannot be done easily I think that both Predis and PhpRedis backends will need to completely split and have totally different implementations for supporting this. This means in the long term completly removing the configuration and connection wrapper at the cost of making the configuration more complex, but would make the module free of maintaining in sync both libraries support.

EDIT: I should start writing a detailed roadmap for 3.0 version.

flbr’s picture

Issue summary: View changes

Sorry to kick this, but I really like to know what the status of this request is. We have two instances of Redis, how will this work with this module?

pounard’s picture

This module will just accept one remote configuration nevertheless it's possible to use multiple Redis servers, you have many choices, both I can tell you directly are:

  • Use a master/slave replication configuration, where you would plug Drupal onto the master and then the slave would just be in sync with the master.
  • Use a proxy assisted sharding using a proxy such as twemproxy, you configure and plug all your servers onto the proxy, then plug Drupal onto the proxy.

Redis official website has plenty of documentation about those various possible configuration, you'll find some links to start with on the Drupal Redis module project page.

pounard’s picture

Status: Active » Postponed

I'm sorry, but this is not the direction will ever take this module I'm afraid, I am trying to make it fast and scalable behind proxy assisted sharding and trying to add multiple server configuration is not in current roadmap. Still, any effort or patch will be considered and reviewed.

pounard’s picture

Status: Postponed » Closed (duplicate)
Related issues: +#2556097: Support cluster connections

Redis server has evolved and now ships with a decent and viable cluster feature. This module will never support reading from slave directly but both connector (Predis and phpredis) are able to work with clusters natively, I'm closing this issue in favor of #2556097: Support cluster connections.