ECS Task Placement Strategies

Home » AWS Cheat Sheets » AWS Compute Services » Compute Related Notes » ECS Task Placement Strategies

ECS Task Placement Strategies

Last updated on February 17, 2023

  • A task placement strategy is an algorithm for selecting instances for task placement or tasks for termination. When a task that uses the EC2 launch type is launched, Amazon ECS must determine where to place the task based on the requirements specified in the task definition, such as CPU and memory. Similarly, when you scale down the task count, Amazon ECS must determine which tasks to terminate. 
  • A task placement constraint is a rule that is considered during task placement.
    • You can use constraints to place tasks based on Availability Zone or instance type. 
    • You can also associate attributes, which are name/value pairs, with your container instances and then use a constraint to place tasks based on attribute.
  • Task placement strategy types:
    • Binpack – Place tasks based on the least available amount of CPU or memory. This minimizes the number of instances in use and allow you to be cost-efficient. For example, you have running tasks in c5.2xlarge instances that are known to be CPU intensive but are not memory consuming. You can maximize your instances’ memory allocation by launching tasks in them instead of spawning a new instance.

ECS Task Placement Strategies

    • Random – Place tasks randomly. You use this strategy when task placement or termination does not matter.
  • Tutorials dojo strip

ECS Task Placement Strategies

    • Spread – Place tasks evenly based on the specified value. Accepted values are attribute key-value pairs, instanceId, or host. Spread is typically used to achieve high availability by making sure that multiple copies of a task are scheduled across multiple instances. Spread across Availability Zones is the default placement strategy used for services.

ECS Task Placement Strategies

  • You can combine different strategy types to suit your application needs.
  • Task placement strategies are a best effort.
  • By default, Fargate tasks are spread across Availability Zones.
  • By default, ECS uses the following placement strategies:
    • When you run tasks with the RunTask API action, tasks are placed randomly in a cluster.
    • When you launch and terminate tasks with the CreateService API action, the service scheduler spreads the tasks across the Availability Zones (and the instances within the zones) in a cluster.

Sources:

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement.html
https://aws.amazon.com/blogs/compute/amazon-ecs-task-placement/

Tutorials Dojo portal

Be Inspired and Mentored with Cloud Career Journeys!

Tutorials Dojo portal

Enroll Now – Our Azure Certification Exam Reviewers

azure reviewers tutorials dojo

Enroll Now – Our Google Cloud Certification Exam Reviewers

Tutorials Dojo Exam Study Guide eBooks

tutorials dojo study guide eBook

FREE AWS Exam Readiness Digital Courses

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

FREE Intro to Cloud Computing for Beginners

FREE AWS, Azure, GCP Practice Test Samplers

Recent Posts

Written by: Jon Bonso

Jon Bonso is the co-founder of Tutorials Dojo, an EdTech startup and an AWS Digital Training Partner that provides high-quality educational materials in the cloud computing space. He graduated from Mapúa Institute of Technology in 2007 with a bachelor's degree in Information Technology. Jon holds 10 AWS Certifications and is also an active AWS Community Builder since 2020.

AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!

Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!

View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses

Our Community

~98%
passing rate
Around 95-98% of our students pass the AWS Certification exams after training with our courses.
200k+
students
Over 200k enrollees choose Tutorials Dojo in preparing for their AWS Certification exams.
~4.8
ratings
Our courses are highly rated by our enrollees from all over the world.

What our students say about us?