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)
],
},
},
}
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.