问题描述
在1个Airflow或Cloud Composer环境中可以运行的DAG数量最大吗?
如果这取决于几个因素(气流基础结构配置,Composer群集规格,每个DAG的活动运行次数等),那么哪些因素会影响此?
解决方法
我从Composer docs中发现Composer使用CeleryExecutor
并在Google Kubernetes Engine(GKE)上运行它。
Airflow中的最大数目没有限制,它是可用资源(节点,CPU,内存)的函数,然后假设有可用资源,Airflow配置选项只是一个限制设置,它将成为瓶颈,必须进行修改。
关于如何在Cloud Composer here中执行此操作,有帮助的指南。因此,一旦您在基础GKE群集中启用了自动扩展,并解锁了Airflow配置中指定的硬限制,就不应限制最大任务数。
对于Vanilla Airflow,这取决于您在Airflow中使用的执行器,并且如果您使用KubernetesExecutor
然后在K8s中处理自动缩放,则将更易于扩展。
如果您使用的是LocalExecutor
,则可以通过增加分配给Airflow安装的资源(CPU,内存)来改善性能,以改善性能。
这取决于气流允许的可用资源以及执行器的类型。在airflow.cfg的[core]部分中定义了允许同时运行的最大任务和dag:
# The amount of parallelism as a setting to the executor. This defines
# the max number of task instances that should run simultaneously
# on this airflow installation
parallelism = 124
# The number of task instances allowed to run concurrently by the scheduler
dag_concurrency = 124
# The maximum number of active DAG runs per DAG
max_active_runs_per_dag = 500