cancel
Showing results for 
Search instead for 
Did you mean: 

Elasticache Redis master/slave

Elasticache Redis master/slave

I am trying to set-up a ElastiCache Redis cluster for default and page_cache.

By reading the documentation of Cm_Cache_Backend_Redis related to the version used by my Magento installation, this seems possible, however I am encountering some difficulties.

After testing different configurations, the best I have been able to achieve is write to master and read from slave, however since I would like to allow read from master as well as described in the documentation.
An example of the configuration I am using to try to achieve this is:

            'default' => [
                'backend' => 'Cm_Cache_Backend_Redis',
                'backend_options' => [
                    'server' => 'cache-001.0001.euw1.cache.amazonaws.com',
                    'database' => '0',
                    'port' => '6379',
                    'compress_data' => '9',
                    'compress_tags' => '1',
                    'compress_threshold' => '1024',
                    'use_lua' => '1',
                    'timeout' => '0.5',
                    'password' => '',
                    'load_from_slaves' => '2',
                    'cluster' => [
                        'master' => [
                            'master-001' => [
                                'server' => 'cache-001.0001.euw1.cache.amazonaws.com',
                                'port' => '6379'
                            ]
                        ],
                        'slave' => [
                            'slave-001' => [
                                'server' => 'cache-002.0001.euw1.cache.amazonaws.com',
                                'port' => '6379'
                            ]
                        ]
                    ]
                ]
            ] 

From what I can see in the code, setting the master node as a node on the slave list should work (but doesn't), as well I have tried to set load_from_slaves to 2 (this should work only on sentinel but seems to have an impact when setting 0 or 1).

For the people that simply want to load from slaves and not achieve read from master as well, this seems to work, only caveat is that you need to set the password parameter (even if empty) or will throw an error.

2 REPLIES 2

Re: Elasticache Redis master/slave

Hi Where you able to find the solution or reason why only cluster config has issues


@dario_martini wrote:

I am trying to set-up a ElastiCache Redis cluster for default and page_cache.

By reading the documentation of Cm_Cache_Backend_Redis related to the version used by my Magento installation, this seems possible, however I am encountering some difficulties.

After testing different configurations, the best I have been able to achieve is write to master and read from slave, however since I would like to allow read from master as well as described in the documentation.
An example of the configuration I am using to try to achieve this is:

            'default' => [
                'backend' => 'Cm_Cache_Backend_Redis',
                'backend_options' => [
                    'server' => 'cache-001.0001.euw1.cache.amazonaws.com',
                    'database' => '0',
                    'port' => '6379',
                    'compress_data' => '9',
                    'compress_tags' => '1',
                    'compress_threshold' => '1024',
                    'use_lua' => '1',
                    'timeout' => '0.5',
                    'password' => '',
                    'load_from_slaves' => '2',
                    'cluster' => [
                        'master' => [
                            'master-001' => [
                                'server' => 'cache-001.0001.euw1.cache.amazonaws.com',
                                'port' => '6379'
                            ]
                        ],
                        'slave' => [
                            'slave-001' => [
                                'server' => 'cache-002.0001.euw1.cache.amazonaws.com',
                                'port' => '6379'
                            ]
                        ]
                    ]
                ]
            ] 

From what I can see in the code, setting the master node as a node on the slave list should work (but doesn't), as well I have tried to set load_from_slaves to 2 (this should work only on sentinel but seems to have an impact when setting 0 or 1).

For the people that simply want to load from slaves and not achieve read from master as well, this seems to work, only caveat is that you need to set the password parameter (even if empty) or will throw an error.


 

Re: Elasticache Redis master/slave

Hi @prakashksinha I ended up changing my approach and separating the different caches to different clusters, then using sentinel.

When looking into it I've seen that the issue might have come from the fact that the version of https://github.com/colinmollenhour/Cm_Cache_Backend_Redis used in Magento is older and might have been buggy. Probably upgrading it could solve this issue, however it might as well create unexpected other errors as I imagine there is a reason why they chose that specific version.