0
votes

I have two identical servers(A and B) synced via Lsyncd. Main server A uses Magento 1.9.1 CE configured with apache, Redis and RDS and uses FPC. I have configured it with custom admin url making A for admin and B for front. I have synced all directories except var and app/etc/local.xml as B has slight modification for redis configuration.

B connects to A's redis instance. Redis is configured for backend cache and session storage. I tested disabling all Cache Types in Cache Management and it worked well but when I enabled them all it gave redis error in B. I disabled 'Configuration' cache type and the error was gone.

The thing thats mysterious is, if I enable 'Configuration' cache type and then do 'flushall' in redis and which ever server A or B loads first and creates backend cache keys the other has this error. Lets say if A loads first then B has redis error. And if done flushall in redis and B loads first then A has redis error.

I can't seem to figure out whats wrong. Here's my redis configuration:

        <session_save>db</session_save>
    <cache>
        <backend>Mage_Cache_Backend_Redis</backend>
        <backend_options>
            <server>127.0.0.1</server>
            <port>6379</port>
            <database>0</database>
            <password>SOME_PASSWORD</password>
            <force_standalone>0</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
            <connect_retries>3</connect_retries>    <!-- Reduces errors due to random connection failures -->
            <automatic_cleaning_factor>0</automatic_cleaning_factor> <!-- Disabled by default -->
            <compress_data>1</compress_data>  <!-- 0-9 for compression level, recommended: 0 or 1 -->
            <compress_tags>1</compress_tags>  <!-- 0-9 for compression level, recommended: 0 or 1 -->
            <compress_threshold>20480</compress_threshold>  <!-- Strings below this size will not be compressed -->
            <compression_lib>gzip</compression_lib> <!-- Supports gzip, lzf and snappy -->
            <persistent>1</persistent> <!-- persistence value, 0: not in use, > 0 used as persistence ID -->
        </backend_options>
    </cache>
    <redis_session>                       <!-- All options seen here are the defaults -->
        <host>127.0.0.1</host>
        <port>6379</port>
        <password>SOME_PASSWORD</password>            <!-- Specify if your Redis server requires authentication -->
        <timeout>2.5</timeout>            <!-- This is the Redis connection timeout, not the locking timeout -->
        <persistent></persistent>         <!-- Specify unique string to enable persistent connections. E.g.: sess-db0; bugs with phpredis and php-fpm are known: https://github.com/nicolasff/phpredis/issues/70 -->
        <db>1</db>                        <!-- Redis database number; protection from accidental loss is improved by using a unique DB number for sessions -->
        <compression_threshold>2048</compression_threshold>  <!-- Set to 0 to disable compression (recommended when suhosin.session.encrypt=on); known bug with strings over 64k: https://github.com/colinmollenhour/Cm_Cache_Backend_Redis/issues/18 -->
        <compression_lib>gzip</compression_lib>              <!-- gzip, lzf or snappy -->
        <log_level>4</log_level>               <!-- 0 (emergency: system is unusable), 4 (warning; additional information, recommended), 5 (notice: normal but significant condition), 6 (info: informational messages), 7 (debug: the most information for development/testing) -->
        <max_concurrency>6</max_concurrency>                 <!-- maximum number of processes that can wait for a lock on one session; for large production clusters, set this to at least 10% of the number of PHP processes -->
        <break_after_frontend>5</break_after_frontend>       <!-- seconds to wait for a session lock in the frontend; not as critical as admin -->
        <break_after_adminhtml>30</break_after_adminhtml>
        <bot_lifetime>7200</bot_lifetime>                    <!-- Bots get shorter session lifetimes. 0 to disable -->
    </redis_session>

The problem is with backend cache i.e. database 0 It doesn't seem to share between different urls.

The Redis error is: Redis error

However, if in B's local.xml i use separate database lets say 2 for backend cache than it has no issue. I want to use same backend cache database for both A and B. Could anyone help me understand whats going on here?

Thanks!

1

1 Answers

0
votes

I found a workaround and the solution seems to make sense. I made identical local.xml files on both servers. The local.xml file in server A, I configured redis to connect to its private ip instead of its local ip 127.0.0.1 for both cache and session. As B needs to connect to redis instance in A now the configuration was same. And then I did flushall redis and it worked. I think Magento stores the configuration in database. So enabling cache type "Configuration" in Cache Management seems to give error especially for front server B, as when A loads first the hostname previously being 127.0.0.1 was saved in database which caused server B with redis connect error as it was trying to connect to itself instead of remote server A.(redis service was stopped in B)

I did some research and found out that it does. This post helped ignite the thought process.

How can I disable the cache via the database?

This was the same with local database. So I used RDS but didn't realize it was the issue related to hostname not being consistent.