如何解决 celery.backends.rpc.BacklogLimitExceeded 错误
How to resolve celery.backends.rpc.BacklogLimitExceeded error
我在工作了很长时间后将 Celery 与 Flask 一起使用,我的 celery 显示 celery.backends.rpc.BacklogLimitExceeded
错误。
我的配置值如下:
CELERY_BROKER_URL = 'amqp://'
CELERY_TRACK_STARTED = True
CELERY_RESULT_BACKEND = 'rpc'
CELERY_RESULT_PERSISTENT = False
谁能解释为什么会出现错误以及如何解决?
我已经检查了文档 here,它没有提供任何解决问题的方法。
可能是因为您使用结果的过程跟不上产生结果的过程?这可能会导致积累大量未处理的结果 - 这就是 "backlog"。当积压的大小超过任意限制时,芹菜会提高BacklogLimitExceeded
。
您可以尝试添加更多消费者来处理结果吗?或者为 the result_expires
setting?
设置一个较短的值
关于this closed celery issue的讨论可能有帮助:
Seems like the database backends would be a much better fit for this purpose.
The amqp/RPC result backends needs to send one message per state update, while for the database based backends (redis, sqla, django, mongodb, cache, etc) every new state update will overwrite the old one.
The "amqp" result backend is not recommended at all since it creates one queue per task, which is required to mimic the database based backends where multiple processes can retrieve the result.
The RPC result backend is preferred for RPC-style calls where only the process that initiated the task can retrieve the result.
But if you want persistent multi-consumer result you should store them in a database.
Using rabbitmq as a broker and redis for results is a great combination, but using an SQL database for results works well too.
我在工作了很长时间后将 Celery 与 Flask 一起使用,我的 celery 显示 celery.backends.rpc.BacklogLimitExceeded
错误。
我的配置值如下:
CELERY_BROKER_URL = 'amqp://'
CELERY_TRACK_STARTED = True
CELERY_RESULT_BACKEND = 'rpc'
CELERY_RESULT_PERSISTENT = False
谁能解释为什么会出现错误以及如何解决? 我已经检查了文档 here,它没有提供任何解决问题的方法。
可能是因为您使用结果的过程跟不上产生结果的过程?这可能会导致积累大量未处理的结果 - 这就是 "backlog"。当积压的大小超过任意限制时,芹菜会提高BacklogLimitExceeded
。
您可以尝试添加更多消费者来处理结果吗?或者为 the result_expires
setting?
关于this closed celery issue的讨论可能有帮助:
Seems like the database backends would be a much better fit for this purpose. The amqp/RPC result backends needs to send one message per state update, while for the database based backends (redis, sqla, django, mongodb, cache, etc) every new state update will overwrite the old one.
The "amqp" result backend is not recommended at all since it creates one queue per task, which is required to mimic the database based backends where multiple processes can retrieve the result.
The RPC result backend is preferred for RPC-style calls where only the process that initiated the task can retrieve the result.
But if you want persistent multi-consumer result you should store them in a database.
Using rabbitmq as a broker and redis for results is a great combination, but using an SQL database for results works well too.