Best practices for Redis service configuration

  • Use the extended Redis cache implementation, which includes the following optimizations to minimize the number of Redis queries that are performed on each request from Adobe Commerce:
    • Diminishes the size of network data transfers between Redis and Adobe Commerce
    • Lowers Redis consumption of CPU cycles by improving the adapter’s ability to automatically determine what needs to be loaded
    • Reduces race conditions on Redis write operations
  • Separate the Redis cache from the Redis session
  • Compress the Redis cache and use gzip to improve performance

Extended Redis cache implementation

Update your configuration to use the extended Redis cache implementation \Magento\Framework\Cache\Backend\Redis.

Configure cloud deployments

Configure enhanced Redis cache by setting the REDIS_BACKEND deployment variable in the .magento.env.yaml configuration file.

    REDIS_BACKEND: '\Magento\Framework\Cache\Backend\Redis'

For details, see the REDIS_BACKEND variable description in the Commerce on Cloud Infrastructure Guide.


Check the ece-tools version installed in your local environment from the command line using the composer show magento/ece-tools command. If necessary, update to the latest version.


Do not configure a Redis slave connection for cloud infrastructure projects with a scaled architecture. This causes Redis connection errors. See the Redis configuration guidance in the Commerce on Cloud Infrastructure guide.

Configure on-premises deployments

For Adobe Commerce on-premises deployments, configure the new Redis cache implementation using the bin/magento:setup commands. For instructions, see Use Redis for default cache.

Separate cache and session instances

Separating the Redis cache from Redis session allows you to manage the cache and sessions independently to prevent cache issues from affecting sessions.

  1. Update the .magento/services.yaml configuration file.

        type: mysql:10.4
        disk: 35000
       type: redis:6.0
    redis-session:              # This is for the new Redis instance
       type: redis:6.0
       type: elasticsearch:7.9
       disk: 5000
       type: rabbitmq:3.8
       disk: 2048
  2. Update the configuration file.

        database: "mysql:mysql"
        redis: "redis:redis"
        redis-session: "redis-session:redis"   # Relationship of the new Redis instance
        search: "search:elasticsearch"
        rabbitmq: "rabbitmq:rabbitmq"
  3. Submit an Adobe Commerce Support ticket to change the Redis service configuration on Pro Production and Staging environments. Include the updated .magento/services.yaml and configuration files.

  4. Verify that the new instance is running and make a note of the port number.

    echo $MAGENTO_CLOUD_RELATIONSHIPS | base64 -d | json_pp
  5. Add the port number to the .magento.env.yaml configuration file.


    disable_locking must be set to 1.

      _merge: true
        port: 6374       # check the port in $MAGENTO_CLOUD_RELATIONSHIPS
        timeout: 5
        disable_locking: 1
        bot_first_lifetime: 60
        bot_lifetime: 7200
        max_lifetime: 2592000
        min_lifetime: 60
  6. Remove sessions from the default database (db 0) on the Redis cache instance.

    redis-cli -h -p 6374 -n 0 FLUSHDB

During deployment, you should see the following lines in the build and deploy log:

W:   - Downloading colinmollenhour/credis (1.11.1)
W:   - Downloading colinmollenhour/php-redis-session-abstract (v1.4.5)
W:   - Installing colinmollenhour/credis (1.11.1): Extracting archive
W:   - Installing colinmollenhour/php-redis-session-abstract (v1.4.5): Extracting archive
[2022-08-17 01:13:40] INFO: Version of service 'redis' is 6.0
[2022-08-17 01:13:40] INFO: Version of service 'redis-session' is 6.0
[2022-08-17 01:13:40] INFO: redis-session will be used for session if it was not override by SESSION_CONFIGURATION

Cache compression

Use cache compression, but be aware that there is a trade-off with client-side performance. If you have spare CPUs, enable it. See Use Redis for session storage.

    REDIS_BACKEND: '\Magento\Framework\Cache\Backend\RemoteSynchronizedCache'
    _merge: true;
              compress_data: 4              # 0-9
              compress_tags: 4              # 0-9
              compress_threshold: 20480     # don't compress files smaller than this value
              compression_lib: 'gzip'       # snappy and lzf for performance, gzip for high compression (~69%)

Additional information

On this page