Cloud Composer 实例节点和自动缩放

Cloud Composer Instance Nodes and Autoscaling

我有几个 DAG,每天只 运行 几个小时,之后 Cloud Composer 集群什么都不做。我正在尝试了解工作人员池自动缩放机制:

Cloud Composer 本身不支持自动缩放,但您可以通过更改气流配置和更改底层 k8s 设置来破解它。

这里有一篇关于如何操作的很棒的文章:https://medium.com/traveloka-engineering/enabling-autoscaling-in-google-cloud-composer-ac84d3ddd60

我决定对@SNeumann 的回答进行更多阐述。至于现在,Composer 不支持启用自动缩放的 Kubernetes 集群。这是因为围绕 Kuberenetes 资源请求以及目前无法估计 Airflow pods 的资源请求存在复杂的对话。

已提交功能请求:1, 2 to support worker autoscaling based on DAG demand. I suggest subscribing it 随时更新,因为您将收到有关其进度的电子邮件。

根据 official documentation:

the Airflow scheduler and workers are in the same GKE cluster, the schedulers and workers won't work properly if the competition results in resource starvation.

现在,您需要在节点级别启用自动缩放并编写 .yaml,然后更新 minReplicas: 1maxReplicas: 50,就像@SNeumann 发布的 Medium 教程中那样。

希望以上信息对您有用。

Environment scaling 现在在 Cloud Composer 2 中得到原生支持:

Cloud Composer 2 brings environments that scale automatically based on the demands of your workflows. For more information about Cloud Composer 2, see Major versions of Cloud Composer, Environment scaling, and Pricing pages in the documentation.

使用 gcloud 命令的示例:

gcloud beta composer composer environments update <ENVIRONMENT_NAME> \
--location <LOCATION> \
--min-workers <WORKERS_MIN> \
--max-workers <WORKERS_MAX>