【问题标题】:Celery Cloudamqp creates new connection for each taskCelery Cloudamqp 为每个任务创建新连接
【发布时间】:2014-06-08 14:44:03
【问题描述】:

我目前正在使用 nitrous.io 运行带有 Celery 的 Django,然后使用 Cloudamqp 作为我的免费计划代理(最多 3 个连接)。我能够很好地连接并启动定期任务。

当我跑步时

    celery -A proj worker  -l info   

在 Cloudamqp 上立即创建了 2 个连接,我可以在第 3 个连接上手动创建多个任务,一切都很好。但是,当我用 celery beat 运行时,

    celery -A proj worker -B -l info

使用所有 3 个连接,如果 celery beat 创建 1 个或多个新任务,将创建另一个第 4 个连接,从而超出允许的最大连接数。

我试过了,目前已经设置了

    BROKER_POOL_LIMIT = 1

但这似乎并没有限制连接 我也试过了

    celery -A proj worker -B -l info
    celery -A proj worker -B -l info -c 1  
    celery -A proj worker -B -l info --autoscale=1,1  -c 1  

没有运气。

为什么立即建立了 2 个什么都不做的连接? 是否以某种方式将初始 celery 连接限制为 0 或 1,或者让任务在 celery beat 连接上共享/运行?

【问题讨论】:

标签: python django celery django-celery cloudamqp


【解决方案1】:

虽然它实际上并没有限制连接,但另一位用户发现禁用连接池实际上会减少连接数: https://stackoverflow.com/a/23563018/1867779

BROKER_POOL_LIMIT = 0

Redis 和 Mongo 后端有自己的连接限制参数。

AMQP 后端没有这样的设置。

鉴于此,我不确定BROKER_POOL_LIMIT 的用途,但我真的很想看看CELERY_AMQP_MAX_CONNECTIONS

这是一个相关的未回答问题:How can I minimise connections with django-celery when using CloudAMQP through dotcloud?

【讨论】:

    猜你喜欢
    • 2012-08-14
    • 1970-01-01
    • 2012-07-09
    • 2014-06-13
    • 1970-01-01
    • 2013-01-07
    • 2013-03-25
    • 2013-06-03
    • 1970-01-01
    相关资源
    最近更新 更多