Cloud Composer Instance Nodes and Autoscaling

5/11/2020

I have a few DAGs that only run for a few hours a day, after which the Cloud Composer cluster does nothing. I'm trying to understand the worker pool auto-scaling mechanism:

  • If I set the cluster size to 3 nodes, but autoscale with min=1, max=10, then set a DAG's concurrency=10, will Composer run on those 3 nodes until the DAG hints at it that it needs for resources, at which point it auto scales to 10 nodes? Then will it destroy those additional 7 nodes when the DAG is done?
-- rodrigo-silveira
airflow
google-cloud-composer
kubernetes

2 Answers

5/13/2020

I have decided to elaborate little bit more to @SNeumann answer. As for now, Composer doesn't support Kubernetes clusters with autoscaling enabled. This is due to there's a complex conversation around Kuberenetes resource requests and how those can't be estimated for Airflow pods at this time.

Feature requests have already been filed: 1, 2 to support worker autoscaling based on DAG demand. I suggest subscribing it to keep updated as you'll receive e-mails regarding its progress.

According to the 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.

For now, you need to enable autoscaling on node level and write .yaml, then update minReplicas: 1 and maxReplicas: 50 like in the Medium tutorial posted by @SNeumann.

I hope you find the above pieces of information useful.

-- muscat
Source: StackOverflow

5/12/2020

Cloud Composer doesn't natively support auto-scaling, but you can hack it by changing airflow config and change the underlying k8s settings.

There's a great article on how to do it here: https://medium.com/traveloka-engineering/enabling-autoscaling-in-google-cloud-composer-ac84d3ddd60

-- SNeumann
Source: StackOverflow