Celery creating a new connection for each task
I ran into the same problem on Heroku with CloudAMQP. I do not know why, but I had no luck when assigning low integers to the BROKER_POOL_LIMIT
setting.
Ultimately, I found that by setting BROKER_POOL_LIMIT=None
or BROKER_POOL_LIMIT=0
my issue was mitigated. According to the Celery docs, this disables the connection pool. So far, this has not been a noticeable issue for me, however I'm not sure if it might be for you.
Link to relevant info: http://celery.readthedocs.org/en/latest/configuration.html#broker-pool-limit
I wish I was using Redis, because there is a specific option to limit the number of connections: CELERY_REDIS_MAX_CONNECTIONS
.
- http://docs.celeryproject.org/en/3.0/configuration.html#celery-redis-max-connections (for 3.0)
- http://docs.celeryproject.org/en/latest/configuration.html#celery-redis-max-connections (for 3.1)
- http://docs.celeryproject.org/en/master/configuration.html#celery-redis-max-connections (for dev)
The MongoDB
has a similar backend setting.
Given these backend settings, I have no idea what BROKER_POOL_LIMIT
actually does. Hopefully CELERY_REDIS_MAX_CONNECTIONS
solves your problem.
I'm one of those folks using CloudAMQP, and the AMQP backend does not have its own connection limit parameter.