简体   繁体   English

菜豆经纪人上的芹菜:任务执行的延迟

[英]celery over beanstalk broker: delays in task execution

TL;DR: TL; DR:

I'm queuing up short and simple tasks to celeryd via a beanstalkd broker, using task.delay (eg myNotifyTask.delay() instead of myNotifyTask() ). 我正在使用task.delay (例如, myNotifyTask.delay()而不是myNotifyTask() )将简短的简单任务celeryd通过beanstalkd经纪人进行task.delay Despite the fact the delay value is supposed to be immediate, tasks take around an hour to execute (when they should take mere seconds). 尽管事实上延迟值应该是即时的,但任务大约需要一个小时才能执行(而它们只需要几秒钟)。

From my observations, it seems the tasks are indeed received in beanstalkd , but stay in a ready state for a very long time. 根据我的观察,似乎任务确实是在beanstalkd接收的,但是要保持ready状态很长时间。 This happens despite setting CELERYD_CONCURRENCY = 8 . 尽管设置了CELERYD_CONCURRENCY = 8还是会发生这种情况。 When viewing beanstalkd 's logs, I get errors about read(): Connection reset by peer , but the tasks do eventually execute. 当查看beanstalkd的日志时,我遇到有关read(): Connection reset by peer错误read(): Connection reset by peer ,但是任务最终会执行。

Any ideas why this could happen? 任何想法为什么会发生这种情况?

Details below. 详细信息如下。


Using beanstalk version 1.4.6, celery 3.0.20. 使用beantalk 1.4.6版,芹菜3.0.20版。

The beanstalk log entries look like this: beantalk日志条目如下所示:

/usr/bin/beanstalkd: prot.c:709 in check_err: read(): Connection reset by peer

When attempting to use celery to diagnose the problems: 尝试使用celery诊断问题时:

> celery -b "beanstalk://beanstalk_server:11300" status
Error: No nodes replied within time constraint.

When connecting to beanstalkd via telnet , I see current-jobs-ready: 343 , which suggests jobs are stuck in the ready state (not delayed ). 通过telnet连接到beanstalkd ,我看到current-jobs-ready: 343 ,这表明作业停留在ready状态(不delayed )。 Here is the full output: 这是完整的输出:

> telnet localhost 11300
stats
OK 850
---
current-jobs-urgent: 343
current-jobs-ready: 343
current-jobs-reserved: 0
current-jobs-delayed: 0
current-jobs-buried: 0
cmd-put: 2484
cmd-peek: 0
cmd-peek-ready: 7
cmd-peek-delayed: 1
cmd-peek-buried: 1
cmd-reserve: 0
cmd-reserve-with-timeout: 52941
cmd-delete: 2141
cmd-release: 0
cmd-use: 2485
cmd-watch: 42
cmd-ignore: 40
cmd-bury: 0
cmd-kick: 0
cmd-touch: 0
cmd-stats: 497655
cmd-stats-job: 2141
cmd-stats-tube: 3
cmd-list-tubes: 2
cmd-list-tube-used: 1
cmd-list-tubes-watched: 52954
cmd-pause-tube: 0
job-timeouts: 0
total-jobs: 2484
max-job-size: 65535
current-tubes: 3
current-connections: 6
current-producers: 2
current-workers: 2
current-waiting: 1
total-connections: 502958
pid: 989
version: 1.4.6
rusage-utime: 45.778861
rusage-stime: 56.595537
uptime: 2489047
binlog-oldest-index: 0
binlog-current-index: 0
binlog-max-size: 10485760

And shortly after: 之后不久:

stats-tube celery
OK 257
---
name: celery
current-jobs-urgent: 348
current-jobs-ready: 348
current-jobs-reserved: 0
current-jobs-delayed: 0
current-jobs-buried: 0
total-jobs: 2739
current-using: 3
current-watching: 1
current-waiting: 0
cmd-pause-tube: 0
pause: 0
pause-time-left: 0

Turns out the problem was that one celery task had a very long timeout, which caused its worker to wait for a long time. 事实证明,一个芹菜任务超时时间很长,这导致其工人要等待很长时间。 Even though concurrency was turned on, the timeouts were simply too long, and the tasks kept piling up in the beanstalk (without celery consuming them, since all the workers eventually get busy). 即使启用了并发功能,超时时间也太长,并且任务不断堆积在豆茎中(没有芹菜消耗它们,因为所有工人最终都变得很忙)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM