Channels: Running multiple instances with same redis backend

Created on 7 Sep 2016  路  3Comments  路  Source: django/channels

Is it possible to use the same redis database for multiple instances of Django + Channels on the same machine?

settings.py

CHANNEL_LAYERS = {
    'default': {
        'BACKEND': 'asgi_redis.RedisChannelLayer',
        'ROUTING': 'project.routing.channel_routing',
        'CONFIG': {
            'hosts': [
                ('localhost', 6379)
            ],
        },
    },
}
question

All 3 comments

I do believe so. I'm using this:

        'CONFIG': {
            'hosts': [
                'redis://127.0.0.1:6379/1',
            ],
        }

I'm using channels and celery in the same project and I understood the "path" (/1) designates the redis database. Celery is using /0 in my project.

Thanks for this hint. Would be still interesting, if there is any conflict between multiple instances in the same redis database.
We are running multiple instances on the same machine and therefor try to use a single redis database part for each django app instance.

It's perfectly fine - either do as above and use database numbers, or use a different prefix in the configuration (the default is asgi) per channel layer cluster.

Was this page helpful?
0 / 5 - 0 ratings