jzahedieh
jzahedieh

Reputation: 1579

Magento Redis Configuration Issue: Cannot find named PHP session module (redis)

I have been dabbling with Redis as a potential solution for our performance woes but I am having issues configuring Redis in Magneto Enterprise 1.13.0.2.

I am getting the following error Warning: session_module_name(): Cannot find named PHP session module (redis)

To me this is saying it does not know of the session handler reddis.

Since EE 1.13 Redis should be available out the box, what is strange is that the full_page_cache works with it but the standard cache and session_save does not.

My local.xml config:

    <session_save><![CDATA[redis]]></session_save>
    <session_save_path><![CDATA[tcp://127.0.0.1:6379?weight=2&timeout=2.5]]></session_save_path>
    <cache>
        <backend>Mage_Cache_Backend_Redis</backend>
        <backend_options>
            <server>127.0.0.1</server> <!-- or absolute path to unix socket -->
            <port>6379</port>
            <persistent></persistent> <!-- Specify a unique string like "cache-db0" to enable persistent connections. -->
            <database>0</database>
            <password></password>
            <force_standalone>0</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
            <connect_retries>1</connect_retries>    <!-- Reduces errors due to random connection failures -->
            <read_timeout>10</read_timeout>         <!-- Set read timeout duration -->
            <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 -->
        </backend_options>
    </cache>
    <full_page_cache>
        <backend>Mage_Cache_Backend_Redis</backend>
        <backend_options>
            <server>127.0.0.1</server> <!-- or absolute path to unix socket -->
            <port>6379</port>
            <persistent></persistent> <!-- Specify a unique string like "cache-db0" to enable persistent connections. -->
            <database>1</database> <!-- Separate database 1 to keep FPC separately -->
            <password></password>
            <force_standalone>0</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
            <connect_retries>1</connect_retries>    <!-- Reduces errors due to random connection failures -->
            <lifetimelimit>57600</lifetimelimit>    <!-- 16 hours of lifetime for cache record -->
            <compress_data>0</compress_data>        <!-- DISABLE compression for EE FPC since it already uses compression -->
        </backend_options>
    </full_page_cache>
</global>

I am having a hard time finding good documentation for it, I could fall back to https://github.com/colinmollenhour/Cm_Cache_Backend_Redis but I would like to use a core package for this funconality and it makes the upgrade path cleaner.

http://www.magentocommerce.com/knowledge-base/entry/redis-magento-ce-ee#config-mage https://magento.stackexchange.com/questions/4264/redis-on-magento-enterprise-1-13

Upvotes: 1

Views: 5277

Answers (2)

jzahedieh
jzahedieh

Reputation: 1579

This has turned out to be a problem with missing the PECL redis extension, so install that and you should be good to go:

pecl install redis

I was under the impression that I could use standalone PHP by using the following:

<force_standalone>1</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->

My full config has ended up being:

    <!-- Uses database 0 -->
    <session_save><![CDATA[redis]]></session_save>
    <session_save_path><![CDATA[tcp://127.0.0.1:6379?weight=2&timeout=2.5]]></session_save_path>
    <cache>
        <backend>Mage_Cache_Backend_Redis</backend>
        <backend_options>
            <server>127.0.0.1</server> <!-- or absolute path to unix socket -->
            <port>6379</port>
            <persistent></persistent> <!-- Specify a unique string like "cache-db0" to enable persistent connections. -->
            <database>1</database> <!-- Separate database 2 to keep separate from FPC + Session -->
            <password></password>
            <force_standalone>0</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
            <connect_retries>1</connect_retries>    <!-- Reduces errors due to random connection failures -->
            <read_timeout>10</read_timeout>         <!-- Set read timeout duration -->
            <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 -->
        </backend_options>
    </cache>
    <full_page_cache>
        <backend>Mage_Cache_Backend_Redis</backend>
        <backend_options>
            <server>127.0.0.1</server> <!-- or absolute path to unix socket -->
            <port>6379</port>
            <persistent></persistent> <!-- Specify a unique string like "cache-db0" to enable persistent connections. -->
            <database>2</database> <!-- Separate database 2 to keep FPC separately -->
            <password></password>
            <force_standalone>1</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
            <connect_retries>1</connect_retries>    <!-- Reduces errors due to random connection failures -->
            <lifetimelimit>57600</lifetimelimit>    <!-- 16 hours of lifetime for cache record -->
            <compress_data>0</compress_data>        <!-- DISABLE compression for EE FPC since it already uses compression -->
        </backend_options>
    </full_page_cache>
</global>

Upvotes: 2

Alana Storm
Alana Storm

Reputation: 166046

I don't do a lot of "dev-ops" type stuff,

Warning: session_module_name(): Cannot find named PHP session module (redis)

is a PHP error, not a Magento error. There is (to my knowledge) no redis backend storage module that ships with PHP.

Per the GitHub for the Cm_RedisSession module, linked in the Magento Wiki Setup page, you're not supposed to set the

`<session_save>`

node in local.xml. Instead

Change the global/session_save configuration to "db" in app/etc/local.xml. The "db" value is the MySQL handler, but Cm_RedisSession overrides it to avoid modifying core files.

with a configuration that looks something like this

<session_save>db</session_save>
<redis_session>                       <!-- All options seen here are the defaults -->
    <host>127.0.0.1</host>            <!-- Specify an absolute path if using a unix socket -->
    <port>6379</port>
    <password></password>             <!-- Specify if your Redis server requires authentication -->
    <timeout>2.5</timeout>          
    <!-- ... more at https://github.com/colinmollenhour/Cm_RedisSession/blob/master/README.md -->

Upvotes: 1

Related Questions