【问题标题】:Delay between celery tasks scheduled by airflow气流安排的芹菜任务之间的延迟
【发布时间】:2017-09-08 20:12:41
【问题描述】:

我试图通过在 Airflow 中使用 celeryExecutor 来运行以下简单的工作流程:

default_args = {
    'depends_on_past': False,
    'start_date': datetime.now(),
}

dag = DAG('HelloWorld', default_args=default_args, schedule_interval=None)
default_args=default_args)

t1 = BashOperator(
    task_id='task_1',
    bash_command='echo "Hello World from Task 1"; sleep 0.1',
    dag=dag)
t2 = BashOperator(
    task_id='task_2',
    bash_command='echo "Hello World from Task 2"; sleep 0.2',
    dag=dag)
t2.set_upstream(t1)

但是,task_1 和 task_2 之间总是有大约 5 秒的延迟。以下是气流.cfg 快照:

[scheduler]
# Task instances listen for external kill signal (when you clear tasks
# from the CLI or the UI), this defines the frequency at which they should
# listen (in seconds).
job_heartbeat_sec = 0.1

# The scheduler constantly tries to trigger new tasks (look at the
# scheduler section in the docs for more information). This defines
# how often the scheduler should run (in seconds).
scheduler_heartbeat_sec = 1

看起来 celery 是导致延迟的原因,但如果属实,如何从气流配置或 API 设置 celery 工作人员心跳间隔(或池化速率)?

【问题讨论】:

  • 将 'start_date' 设置为 datetime.now() 可能会出现一些问题,请参阅“使用 datetime.now() 的 start_date 会导致不可预知的行为,并且您的 DAG 永远不会启动。建议减去时间跨度以强制调度程序识别 start_date。***"
  • 您能否更具体地说明start_date 应该是什么?请注意,我的schedule_interval 已设置为None
  • 对不起,我看错了信息,看起来这是意料之中的,请看这里 - groups.google.com/forum/#!topic/airbnb_airflow/dNskpaOYNQo

标签: celery airflow


【解决方案1】:

作为批处理调度程序,Airflow 目前不保证超低延迟。该项目的目标是使大规模的亚分钟延迟成为可能,但在较大的环境中通常会达到几分钟。

如果延迟时间约为 1 分钟,则执行 1-2 秒的任务链是没有意义的。通常,Airflow 任务的持续时间应该以分钟计算,而不是秒(但也有例外)。 Airflow 不是 Amazon Lambda。

也许可以微调并说

【讨论】:

    猜你喜欢
    • 2018-09-28
    • 2020-03-04
    • 1970-01-01
    • 2013-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-06
    • 1970-01-01
    相关资源
    最近更新 更多