Search code examples
sessionmagentocachingredismagento-1.9

Is it a bad idea to use a single Redis instance for both session and backend caching in Magento?


For Magento (v1.9 or lower), is okay to use a single Redis instance for both session and backend caching? Is there any extra configuration required?


Solution

  • After further research, it seems like using the same instance for both session and backend cache is easy to do with the only potential problem being running out of space (not an issue if you're on AWS using ElastiCache).

    Different port numbers are also not necessary. You just need to specify different "database numbers". The following is an example config:

      <cache>
        <backend>Cm_Cache_Backend_Redis</backend>
        <backend_options>
          <server>$REDIS_CACHE</server>
          <port>6379</port>
          <persistent></persistent>
          <database>1</database> <!-- DIFFERENT DB NUMBER -->
          <password></password>
          <force_standalone>0</force_standalone>
          <connect_retries>1</connect_retries>
          <read_timeout>10</read_timeout>
          <automatic_cleaning_factor>0</automatic_cleaning_factor>
          <compress_data>1</compress_data>
          <compress_tags>1</compress_tags>
          <compress_threshold>20480</compress_threshold>
          <compression_lib>gzip</compression_lib>
          <use_lua>0</use_lua>
        </backend_options>
      </cache>
      <session_save>db</session_save>
      <redis_session>
        <host>$REDIS_CACHE</host>
        <port>6379</port>
        <password></password>
        <timeout>2.5</timeout>
        <persistent></persistent>
        <db>2</db> <!-- DIFFERENT DB NUMBER -->
        <compression_threshold>2048</compression_threshold>
        <compression_lib>gzip</compression_lib>
        <log_level>1</log_level>
        <max_concurrency>6</max_concurrency>
        <break_after_frontend>5</break_after_frontend>
        <fail_after>10</fail_after>
        <break_after_adminhtml>30</break_after_adminhtml>
        <first_lifetime>600</first_lifetime>
        <bot_first_lifetime>60</bot_first_lifetime>
        <bot_lifetime>7200</bot_lifetime>
        <disable_locking>0</disable_locking>
        <min_lifetime>60</min_lifetime>
        <max_lifetime>2592000</max_lifetime>
      </redis_session>