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
Comment #1
pounard@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.
Comment #2
iler commented@jtsnow Any progress on this one?
Comment #3
npscode commentedHi 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..
Comment #4
jtsnow commentedI did have slave reads working in a Drupal 6 implementation. I have not yet ported that to this module.
Comment #5
bibo commentedI'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?
Comment #6
pounardI need to do this. Any patch are welcome.
Comment #7
pounardBack 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?
Comment #8
pounard@#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.
Comment #9
pounardAlso forgotten this one http://redis.io/topics/cluster-spec
Comment #10
iler commented@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.
Comment #11
iler commented@pounard this seems to be a good starting point http://souvikroy.com/2012/01/08/a-simple-wrapper-around-phpredis-for-rou...
Comment #12
pounardSomebody 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.
Comment #13
flbr commentedSorry 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?
Comment #14
pounardThis 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:
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.
Comment #15
pounardI'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.
Comment #16
pounardRedis 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.