Tyler
Tyler

Reputation: 2386

max number of clients reached celery

I am using django with celery and redis. I keep getting this error redis.exceptions:ResponseError max number of clients reached I am using heroku and my redis backend has max connection of 400. I running 20 dynos for the main app and for celery I am running 5 dynos. How do I set the max number of connections? I've tried putting it in my celery.py like so:

from __future__ import absolute_import

import os

from celery import Celery

# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'imdowntags.settings')

from django.conf import settings
app = Celery('imdowntags',
             broker=os.environ['REDIS_URL'],
             backend=os.environ['REDIS_URL'],
             include=['imdowntags.tasks'])

# Using a string here means the worker will not have to
# pickle the object when using Windows.
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
app.conf.update( CELERY_REDIS_MAX_CONNECTIONS = 20,)

also have tried putting

CELERY_REDIS_MAX_CONNECTIONS =20

inside of my settings.py

Upvotes: 3

Views: 5747

Answers (1)

bimsapi
bimsapi

Reputation: 5065

You are probably hitting a plan limit on the Redis server itself. If you are using the Heroku Redis addon, consult the plan descriptions: https://elements.heroku.com/addons/heroku-redis

You should expect a minimum of 1 connection for each dyno - for web dynos to queue stuff up, and the celery workers to pop stuff off. 20 web + 5 celery easily puts you over the for the free tier.

Upvotes: 6

Related Questions