4

I have Airflow jobs, which are running fine on the EMR cluster. what I need is, let's say if I have a 4 airflow jobs which required an EMR cluster for let's say 20 min to complete the task. why not we can create an EMR cluster at DAG run time and once the job is to finish it will terminate the created an EMR cluster.

gaurav agnihotri
  • 193
  • 1
  • 3
  • 12

3 Answers3

9

Absolutely, that would be the most efficient use of resources. Let me warn you: there are a lot of details in this; I'll try to list as many as would get you going. I encourage you to add your own comprehensive answer listing any problems that you encountered and the workaround (once you are through this)


Regarding cluster creation / termination


Regarding job submission


y2k-shubham
  • 8,431
  • 10
  • 45
  • 111
  • Thanks for your detail support, I have two clouds setup. Google and AWS. Can we have something like this in GCP as well? – gaurav agnihotri Mar 19 '19 at 04:25
  • `Airflow` has [quite a few](https://imgur.com/D1F02Fc) `hook`s / `operator`s for `Google Cloud` as well. And of course [`Google Cloud Composer`](https://cloud.google.com/blog/products/gcp/cloud-composer-is-now-in-beta-build-and-run-practical-workflows-with-minimal-effort) is fully managed service. Unfortunately I haven't worked with `GCP`, so can't tell you any more than this – y2k-shubham Mar 19 '19 at 06:25
0

The best way to do this is probably to have a node at the root of your Airflow DAG that creates the EMR cluster, and then another node at the very end of the DAG that spins the cluster down after all of the other nodes have completed.

Max Gasner
  • 1,106
  • 11
  • 17
0

Check my implementation, DAG will create emr cluster and run the spark job against the data in s3 and terminate automatically once done.

https://beyondexperiment.com/vijayravichandran06/aws-emr-orchestrate-with-airflow/

vijay
  • 49
  • 1
  • 2