本文介绍了芹菜心跳不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Celery 设置中设置了心跳:

I have set heartbeat in Celery settings:

BROKER_HEARTBEAT = 10

我也在 RabbitMQ config 中设置了这个配置值:

I have also set this configuration value in RabbitMQ config:

'heartbeat' => '10',

但不知何故心跳仍然被禁用:

But somehow heartbeats are still disabled:

ubuntu@sync1:~$ sudo rabbitmqctl list_connections name timeout
Listing connections ...
some_address:37781 -> other_address:5672    0
some_address:37782 -> other_address:5672    0
...done.

任何想法我做错了什么?

Any ideas what am I doing wrong?

更新:

所以现在我明白了:

ubuntu@sync1:/etc/puppet$ sudo rabbitmqctl list_connections name timeout
Listing connections ...
some_address:41281 -> other_address:5672    10
some_address:41282 -> other_address:5672    10
some_address:41562 -> other_address:5672    0
some_address:41563 -> other_address:5672    0
some_address:41564 -> other_address:5672    0
some_address:41565 -> other_address:5672    0
some_address:41566 -> other_address:5672    0
some_address:41567 -> other_address:5672    0
some_address:41568 -> other_address:5672    0
...done.

我有 3 台服务器:

  • RabbitMQ 代理
  • RESTful API 服务器
  • 远程工作服务器

看来远程被妖魔化的 Celery 工人正确地发送了心跳.使用 Celery 远程处理任务的 RESTful API 服务器由于某种原因没有使用心跳.

It appears the remote demonised Celery workers send heartbeats correctly. The RESTful API server using Celery to remotely process tasks is not using heartbeat for some reason.

推荐答案

celery worker的心跳是应用层的心跳,不是AMQP协议的心跳.每个工作人员定期向 BROKER 中的celeryev"事件交换发送心跳事件消息.心跳事件被转发回worker,这样worker就可以知道BROKER的健康状态.如果丢失心跳的次数超过阈值,worker 可以对 BROKER 执行一些重新连接操作.

the heartbeat of celery worker is application level heartbeat, not AMQP protocol's heartbeat.Each worker periodically send heartbeat event message to "celeryev" event exchange in BROKER.The heartbeat event is forwarded back to worker such worker can know the health status of BROKER.If number of loss heartbeat exceeding a threshold, the worker can do some reconnect action to BROKER.

有关其他详细信息,您可以查看此 页面BROKER_FAILOVER_STRATEGY 部分描述了从 BROKER 中删除可以执行的操作.

For the rest of detail, you may check this pageThe section: BROKER_FAILOVER_STRATEGY describes the actions you may do for dropping from a BROKER.

这篇关于芹菜心跳不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-29 08:21