Optimizing Python Script Execution on ECS with Apache Airflow: Cost-effective Strategies

0

"I have multiple Python scripts stored within a Docker image, each with its set of input parameters. My goal is to execute these scripts on Amazon Elastic Container Service (ECS) as required. Inside the Docker image,

I have the following scripts:

• ex-tract_satellite_data.py

• calculates_ndvi.py

These scripts rely on various input parame-ters like 'sensor' (e.g., 'sentinel2') and 'config_file' (a YAML file with start and end dates, etc.).

Currently, we're using ECS and EFS to run these Python scripts. The scripts are executed using ECS tasks, and the required files are mounted in EFS. To further streamline this process, we're considering automating the ECS task runs using Apache Airflow. However, we're facing cost concerns with AWS Managed Apache Airflow (MWAA), as it lacks the option to pause when not in use.

Considering this, we're exploring the most cost-effective way to manage this workflow. We're contemplating whether to set up our own Apache Airflow instance on an EC2 instance or continue with AWS Managed Apache Airflow. Are there any alternative solutions or best practices for managing this process efficiently and economically?

Your insights and recommendations would be greatly appreciated."

1개 답변
0

Hi,

A more cost-effective solution will be to use EventBridge to schedule a Lambda that will start / stop your ECS tasks: see https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-run-lambda-schedule.html for a tutorial.

An intro to this service is here: https://aws.amazon.com/blogs/compute/introducing-amazon-eventbridge-scheduler/

You cannot manage the sophisticated DAGs possible in Airflows. But, your use case seems simple: so, it should fit.

Custom events like the one you will publish to trigger the lambda : $1.00/million custom events published. See https://aws.amazon.com/eventbridge/pricing/. You have to add also the costs of running the Lambdas when starting/stopping but here also it should remain very small.

Best,

Didier

profile pictureAWS
전문가
답변함 8달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인