Hi,
We've been using this module successfully in production for a few years, but lately started having problems with performance in our Redis cluster (we're using Elasticache).
We're using Cluster Disabled and would like to use a node replica to alleviate load.
Looking at the docs it's not completely clear to me how we can achieve this.
Using PHPRedis
We're currently using PHPRedis and ideally we'd like to keep doing so, however, the replication examples in the README don't seem to apply to it. Is that supported? If so, how do I achieve this?
Using Predis
Assuming it's not possible to keep using PHPRedis, we'd need to transition to Predis, although it says it's experimental still. How successfully is this being used in production systems?
For testing purposes I setup some replica nodes in a staging environment and tried to configure things as per README docs, like so:
$settings['redis.connection']['interface'] = 'Predis'; // Use predis library.
$settings['redis.connection']['replication'] = TRUE; // Turns on replication.
$settings['redis.connection']['replication.host'][1]['host'] = '1.2.3.4'; // Your Redis instance hostname.
$settings['redis.connection']['replication.host'][1]['port'] = '6379'; // Only required if using non-standard port.
$settings['redis.connection']['replication.host'][1]['role'] = 'primary'; // The redis instance role.
$settings['redis.connection']['replication.host'][2]['host'] = '1.2.3.5';
$settings['redis.connection']['replication.host'][2]['port'] = '6379';
$settings['redis.connection']['replication.host'][2]['role'] = 'replica';
However, when I do this I get the following error:
InvalidArgumentException: Predis\Configuration\Option\Replication expects either a string or a callable value, boolean given in Predis\Configuration\Option\Replication->filter() (line 40 of /var/www/html/vendor/predis/predis/src/Configuration/Option/Replication.php).
Debugging this, it seems like a string is expected (for the replication flag), but in the README we're passing a boolean. If I change the paremeter to be a string "true" however, then that breaks in the Drupal's Redis implementation, specifically here in ClientFactory:
// If using replication, lets create the client appropriately.
if (isset($settings['replication']) && $settings['replication'] === TRUE) {
foreach ($settings['replication.host'] as $key => $replicationHost) {
if (!isset($replicationHost['port'])) {
$settings['replication.host'][$key]['port'] = self::REDIS_DEFAULT_PORT;
}
}
Can someone assist me with this one?
Thanks in advance!
Comment | File | Size | Author |
---|---|---|---|
#6 | redis-replication-3.patch | 1.21 KB | juanl |
#4 | redis-replication.patch | 1.49 KB | juanl |
Comments
Comment #2
yi_jiang CreditAttribution: yi_jiang as a volunteer commentedHi It has been for a while, I totally forgot how I did last time, this is my original patch, see if it helps you.
Comment #3
kyuubi CreditAttribution: kyuubi as a volunteer commentedThanks @yi_jiang,
However this seems to be for Predis. That seems to be slower and less supported.
I'm interested in a solution using PhpRedis.
Comment #4
juanl CreditAttribution: juanl as a volunteer commentedin case this helps someone, the attached patch enable replication.
Status detail page only show master role, it should be extended to the replicas as well.
Comment #5
juanl CreditAttribution: juanl as a volunteer commentedComment #6
juanl CreditAttribution: juanl as a volunteer commentedComment #7
firewaller CreditAttribution: firewaller commented#6 works for me