Shopware Increment Storage with Redis

By default, Shopware stores the increment storage on the file system in a transaction-safe manner, which leads to locks in the memory. The database table increment is used for this by default.

If several message consumers are executed, this table can often be locked, which can affect the performance of the worker. The Linux-based in-memory service Redis provides a remedy here.


Preparation in Shopware

First, a Redis server must be made available for the server. This can either be set up locally on the app server or externally, e.g. via an accelerator server. You can find more information about our accelerator servers here: https://www.creoline.com/de/products/redis-server



Configuration via the Shopware environment configuration

Create a new configuration file under the path: config/packages/storage.yaml. This configuration file can be used to configure the session. Then add the following content to the file:

shopware:
    increment:
        user_activity:
          type: 'redis'
          config:
            url: 'redis://%env(REDIS_HOST)%:%env(REDIS_PORT)%/%env(REDIS_DB_STORAGE)%'

        message_queue:
          type: 'redis'
          config:
            url: 'redis://%env(REDIS_HOST)%:%env(REDIS_PORT)%/%env(REDIS_DB_STORAGE)%'


The following environment variables are used in this configuration file:

Variable Description
REDIS_HOST Host name or IP address for the Redis server
REDIS_PORT TCP port for Redis connections (default: 6379)
REDIS_DB_STORAGE Redis database for Increment Storage


The variables used here must then be added to the Shopware environment configuration .env.local. To do this, open the .env.local file in the Shopware root directory and add the following part to the existing configuration:

# .env.local

# [...]

# Increment Storage Configuration
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_DB_STORAGE=2


Then save the file and empty the Shopware cache via the console:

bin/console cache:clear


The Redis server is then used to manage the increment storage.



Shopware provides further information and adapters in the official documentation.

To the Shopware documentation →