SlideShare a Scribd company logo
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Julien Simon
Principal Technical Evangelist, AWS
@julsimon
Advanced Task Scheduling
with Amazon ECS
Docker on Amazon Web Services
Amazon EC2 Container Service (ECS)
• https://aws.amazon.com/ecs/
• Launched in 04/2015
• No additional charge
Amazon EC2 Container Registry (ECR)
• https://aws.amazon.com/ecr/
• Launched in 12/2015
• Free tier: 500MB / month for a year
• $0.10 / GB / month + outgoing traffic
Both services are available in US, EU and APAC
ECS adoption
https://www.datadoghq.com/blog/3-clear-trends-in-ecs-adoption/
November 2016
Companies
Selected ECS customers
Container Partners
https://aws.amazon.com/containers/partners/
ECS Scheduling
The problem
Given a certain amount of
computing power and memory,
how can we best manage
an arbitrary number of apps
running in Docker containers?
http://tidalseven.com
Amazon ECS: Under the Hood
ALB ALB
AZ 1 AZ 2
user / scheduler
https://github.com/aws/amazon-ecs-agenthttp://www.allthingsdistributed.com/2015/07/under-the-hood-of-the-amazon-ec2-container-service.html
Scheduling on ECS: two options so far
1. Let ECS handle scheduling through Services
• Task Definition
• ECS transcription of the Docker Compose file
• Versioning
• cpu_shares, mem_limit
• Number of desired containers
2. Implement a custom scheduler with the ECS API
• Describe cluster state
• Select a specific ECS instance according to custom logic
• Run task on this instance
• Coursera use case: www.youtube.com/watch?v=a45J6xAGUvA
ECS Placement Engine
Placement Engine: giving developers more
control
ALB ALB
AZ 1 AZ 2
user / scheduler
Placement Engine
Constraints
& Strategies
Placement Constraints
Name Example
AMI ID attribute:ecs.ami-id == ami-eca289fb
Availability Zone attribute:ecs.availability-zone == us-east-1a
Instance Type attribute:ecs.instance-type == t2.small
Distinct Instances type=“distinctInstance”
Custom attribute:stack == prod
Example: Constraint on Instance Family/Type
Example: Constraint on Availability Zone
Example: Combining Multiple Constraints
Placement Strategies
Binpacking Spread Affinity Distinct Instance
Placement Strategy Chaining
Spread tasks across Zones
and Binpack within each Zone
Placing Tasks
Anatomy of Task Placement
Cluster Constraints
Custom Constraints
Placement Strategies
Apply Filter
Satisfy CPU, memory, and port requirements
Filter for location, instance-type, AMI, or custom
attribute constraints
Identify instances that meet spread or binpack
placement strategy
Select final container instances for placement
g2.2xlarge t2.small g2.2xlarge g2.2xlarge
Placement: Targeting Instance Type
g2.2xlarge t2.small t2.micro t2.medium
t2.medium t2.small g2.2xlarge
t2.small
t2.small t2.medium
us-east-1aus-east-1d
Placement: Targeting Instance Type & Zone
g2.2xlarge t2.small t2.micro t2.medium
t2.medium t2.small g2.2xlarge t2.small
us-east-1aus-east-1d
g2.2xlarge t2.medium
t2.micro t2.small
us-east-1c
Placement: Availability Zone Spread
g2.2xlarge t2.small t2.micro t2.medium
t2.medium t2.small g2.2xlarge t2.small
us-east-1aus-east-1d
g2.2xlarge t2.medium
t2.micro t2.small
us-east-1c
Placement: Spread across Zone and Binpack
g2.2xlarge t2.small t2.micro t2.medium
t2.medium t2.small g2.2xlarge t2.small
us-east-1aus-east-1d
g2.2xlarge t2.medium
t2.micro t2.small
us-east-1c
Placement: Affinity and Anti-Affinity
Running a Service
t2.medium t2.small t2.small
us-east-1aus-east-1d
t2.medium t2.micro t2.small
us-east-1c
Placement: Multiple Services on a Cluster
t2.medium g2.2xlarge t2.micro t2.small
t2.small t2.small g2.2xlarge t2.small
t2.small t2.small
g2.2xlarge t2.small
Placement: Services – Distinct Instances
Event Stream & Blox
Amazon ECS: Under the Hood
ALB ALB
AZ 1 AZ 2
user / scheduler
Placement Engine
Event Stream
Consuming Real-time Events
Handling ECS events with Blox
scheduler cluster state service
https://blox.github.io/
Amazon ECS: Under the Hood
ALB ALB
AZ 1 AZ 2
user / scheduler
Scheduler
Cluster State Service
Placement Engine
Event Stream
t2.small t2.small t2.small
Blox: Daemon Scheduler
t2.small t2.small t2.small
scheduler cluster state service
t2.small t2.small t2.small
Demo: Deploying Blox on AWS
Creating Clusters
Create an ECS cluster for Blox
CF template: https://github.com/blox/blox/blob/dev/deploy/aws/conf/cloudformation_template.json
à CloudWatch Event Rule + SQS queue
à 3 containers: Daemon Scheduler + Cluster State Service + etcd
à REST API exposing the Daemon Scheduler API
Create another ECS cluster managed by Blox
$ ecs-cli configure --cluster WebCluster
$ ecs-cli up --keypair admin --capability-iam --size 3 --instance-type t2.micro
Invoke the scheduler API
‘demo-cli’ tool: https://github.com/blox/blox/tree/dev/deploy/demo-cli
Listing Task Definitions
Grab the ARN for an nginx Task Definition, which the
Daemon Scheduler will manage on ‘WebCluster’.
$ ./list-task-definitions.py --region eu-central-1
== Blox Demo CLI - List Task Definitions ==
{
"taskDefinitionArns": [
"arn:aws:ecs:eu-central-1:ACCOUNT:task-definition/BloxFramework:2",
"arn:aws:ecs:eu-central-1:ACCOUNT:task-definition/nginx:1",
"arn:aws:ecs:eu-central-1:ACCOUNT:task-definition/nginx:2"
]
}
Creating an Environment
$ ./blox-create-environment.py --environment WebEnvironment --cluster
WebCluster --task-definition "arn:aws:ecs:eu-central-1:ACCOUNT:task-
definition/nginx:2" --stack Blox --apigateway --region eu-central-1
== Blox Demo CLI - Create Blox Environment ==
HTTP Response Code: 200
{
"taskDefinition": "arn:aws:ecs:eu-central-1:ACCOUNT:task-definition/nginx:2",
"deploymentToken": "17248257-08ec-4438-888f-e0ac28397653",
"health": "healthy",
"name": "WebEnvironment",
"instanceGroup": {
"cluster": "arn:aws:ecs:eu-central-1:ACCOUNT:cluster/WebCluster"
}
}
Listing Environments
$ ./blox-list-environments.py --stack Blox --apigateway --region eu-central-1
== Blox Demo CLI - List Blox Environments ==
HTTP Response Code: 200
{
"items": [
{
"taskDefinition": "arn:aws:ecs:eu-central-1:ACCOUNT:task-definition/nginx:2",
"deploymentToken": "17248257-08ec-4438-888f-e0ac28397653",
"health": "healthy",
"name": "WebEnvironment",
"instanceGroup": {
"cluster": "arn:aws:ecs:eu-central-1:ACCOUNT:cluster/WebCluster"
}
}
]
}
Creating a Deployment
$ ./blox-create-deployment.py --environment WebEnvironment
--deployment-token "17248257-08ec-4438-888f-e0ac28397653"
--stack Blox --apigateway --region eu-central-1
== Blox Demo CLI - Create Blox Deployment ==
HTTP Response Code: 200
{
"status": "pending",
"environmentName": "WebEnvironment",
"id": "7a05ea99-27a9-4339-a7a6-f4120065aea3",
"failedInstances": [],
"taskDefinition": "arn:aws:ecs:eu-central-1:613904931467:task-definition/nginx:2”
}
Listing Deployments
$ ./blox-list-deployments.py --environment WebEnvironment --stack Blox
--apigateway --region eu-central-1
== Blox Demo CLI - List Blox Deployments ==
HTTP Response Code: 200
{
"items": [
{
"status": "completed",
"environmentName": "WebEnvironment",
"id": "7a05ea99-27a9-4339-a7a6-f4120065aea3",
"failedInstances": [],
"taskDefinition": "arn:aws:ecs:eu-central-1:ACCOUNT:task-definition/nginx:2"
}
]
}
Scaling a Deployment
$ ecs-cli ps
Name State Ports TaskDefinition
26313cbe-d929-49de-9cc3-873bf5f32a91/nginx RUNNING nginx:2
98442432-fd5c-434d-b93c-0737bd06aaab/nginx RUNNING nginx:2
ce9bf217-4b34-4f31-9c7b-a8c3402f1ffd/nginx RUNNING nginx:2
$ ecs-cli scale --size 4 --capability-iam
$ ecs-cli ps
Name State Ports TaskDefinition
26313cbe-d929-49de-9cc3-873bf5f32a91/nginx RUNNING nginx:2
98442432-fd5c-434d-b93c-0737bd06aaab/nginx RUNNING nginx:2
c404ac9a-0948-4cc8-b5b0-2238ccdf4035/nginx RUNNING nginx:2
ce9bf217-4b34-4f31-9c7b-a8c3402f1ffd/nginx RUNNING nginx:2
Additional resources
ECS customers
https://www.mapbox.com/blog/switch-to-ecs/
https://segment.com/blog/rebuilding-our-infrastructure/
Tech articles by Werner Vogels, CTO, Amazon.com
http://www.allthingsdistributed.com/2014/11/amazon-ec2-container-service.html
http://www.allthingsdistributed.com/2015/04/state-management-and-scheduling-with-ecs.html
http://www.allthingsdistributed.com/2015/07/under-the-hood-of-the-amazon-ec2-container-service.html
Blog articles & videos
https://aws.amazon.com/blogs/compute/amazon-ec2-container-service-at-aws-reinvent-2016-wrap-up/
https://aws.amazon.com/blogs/compute/continuous-deployment-to-amazon-ecs-using-aws-codepipeline-
aws-codebuild-amazon-ecr-and-aws-cloudformation/
Thank you!
Julien Simon
Principal Technical Evangelist, AWS
@julsimon

More Related Content

What's hot (20)

PPTX
From Docker to Production - ZendCon 2016
Chris Tankersley
 
PDF
Kubernetes Basis: Pods, Deployments, and Services
Jian-Kai Wang
 
PDF
開放運算&GPU技術研究班
Paul Chao
 
PDF
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd について
LINE Corporation
 
PDF
KubeCon EU 2016: A Practical Guide to Container Scheduling
KubeAcademy
 
PPTX
From Docker to Production - SunshinePHP 2017
Chris Tankersley
 
PDF
Using Nix and Docker as automated deployment solutions
Sander van der Burg
 
PDF
Dockerを利用したローカル環境から本番環境までの構築設計
Koichi Nagaoka
 
PPTX
Monitoring, Logging and Tracing on Kubernetes
Martin Etmajer
 
PDF
nix-processmgmt: An experimental Nix-based process manager-agnostic framework
Sander van der Burg
 
PDF
Docker Swarm 0.2.0
Docker, Inc.
 
PDF
Deep Dive into Docker Swarm Mode
Ajeet Singh Raina
 
PDF
Kubernetes for Java developers
Robert Barr
 
PDF
Automatically Renew Certificated In Your Kubernetes Cluster
HungWei Chiu
 
PDF
KubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
KubeAcademy
 
PDF
Docker meetup - PaaS interoperability
Ludovic Piot
 
PPTX
Dockerizing a multi-component Open Data app
Stergios Tsiafoulis
 
ODP
Why Docker? Dayton PHP, April 2017
Chris Tankersley
 
PDF
Scaling docker with kubernetes
Liran Cohen
 
PDF
[DockerCon 2019] Hardening Docker daemon with Rootless mode
Akihiro Suda
 
From Docker to Production - ZendCon 2016
Chris Tankersley
 
Kubernetes Basis: Pods, Deployments, and Services
Jian-Kai Wang
 
開放運算&GPU技術研究班
Paul Chao
 
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd について
LINE Corporation
 
KubeCon EU 2016: A Practical Guide to Container Scheduling
KubeAcademy
 
From Docker to Production - SunshinePHP 2017
Chris Tankersley
 
Using Nix and Docker as automated deployment solutions
Sander van der Burg
 
Dockerを利用したローカル環境から本番環境までの構築設計
Koichi Nagaoka
 
Monitoring, Logging and Tracing on Kubernetes
Martin Etmajer
 
nix-processmgmt: An experimental Nix-based process manager-agnostic framework
Sander van der Burg
 
Docker Swarm 0.2.0
Docker, Inc.
 
Deep Dive into Docker Swarm Mode
Ajeet Singh Raina
 
Kubernetes for Java developers
Robert Barr
 
Automatically Renew Certificated In Your Kubernetes Cluster
HungWei Chiu
 
KubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
KubeAcademy
 
Docker meetup - PaaS interoperability
Ludovic Piot
 
Dockerizing a multi-component Open Data app
Stergios Tsiafoulis
 
Why Docker? Dayton PHP, April 2017
Chris Tankersley
 
Scaling docker with kubernetes
Liran Cohen
 
[DockerCon 2019] Hardening Docker daemon with Rootless mode
Akihiro Suda
 

Viewers also liked (19)

PPTX
DevOps, NoOps, everything-as-code, commoditisation… Quel futur pour les ops ?
Adrien Blind
 
PPTX
When Docker Engine 1.12 features unleashes software architecture
Adrien Blind
 
PPTX
DevOps à l'échelle: ce que l'on a fait, ce que l'on a appris chez Societe Gen...
Adrien Blind
 
PPTX
Docker cloud hybridation & orchestration
Adrien Blind
 
PPTX
Full stack automation - TIAD 2015
Adrien Blind
 
PPTX
Docker, cornerstone of cloud hybridation ? [Cloud Expo Europe 2016]
Adrien Blind
 
PPTX
Docker, cornerstone of an hybrid cloud?
Adrien Blind
 
PPTX
Docker, Pierre angulaire du continuous delivery ?
Adrien Blind
 
PPTX
The missing piece : when Docker networking and services finally unleashes so...
Adrien Blind
 
PPTX
Skynet vs planet of apes
Adrien Blind
 
PPTX
Identity & Access Management in the cloud
Adrien Blind
 
PPTX
Dockercon Europe 2014 - Continuous Delivery leveraging on Docker CaaS
Adrien Blind
 
PDF
Monitoring de conteneurs en production - Jonathan Raffre & Jean-Pascal Thiery
Paris Container Day
 
PPTX
Docker: Redistributing DevOps cards, on the way to PaaS
Adrien Blind
 
PPTX
Petit déjeuner Octo - L'infra au service de ses projets
Adrien Blind
 
PPTX
Continous delivery at docker age
Adrien Blind
 
PPTX
DevOps at scale: what we did, what we learned at Societe Generale
Adrien Blind
 
PPTX
Introduction to Unikernels at first Paris Unikernels meetup
Adrien Blind
 
PPTX
Docker networking basics & coupling with Software Defined Networks
Adrien Blind
 
DevOps, NoOps, everything-as-code, commoditisation… Quel futur pour les ops ?
Adrien Blind
 
When Docker Engine 1.12 features unleashes software architecture
Adrien Blind
 
DevOps à l'échelle: ce que l'on a fait, ce que l'on a appris chez Societe Gen...
Adrien Blind
 
Docker cloud hybridation & orchestration
Adrien Blind
 
Full stack automation - TIAD 2015
Adrien Blind
 
Docker, cornerstone of cloud hybridation ? [Cloud Expo Europe 2016]
Adrien Blind
 
Docker, cornerstone of an hybrid cloud?
Adrien Blind
 
Docker, Pierre angulaire du continuous delivery ?
Adrien Blind
 
The missing piece : when Docker networking and services finally unleashes so...
Adrien Blind
 
Skynet vs planet of apes
Adrien Blind
 
Identity & Access Management in the cloud
Adrien Blind
 
Dockercon Europe 2014 - Continuous Delivery leveraging on Docker CaaS
Adrien Blind
 
Monitoring de conteneurs en production - Jonathan Raffre & Jean-Pascal Thiery
Paris Container Day
 
Docker: Redistributing DevOps cards, on the way to PaaS
Adrien Blind
 
Petit déjeuner Octo - L'infra au service de ses projets
Adrien Blind
 
Continous delivery at docker age
Adrien Blind
 
DevOps at scale: what we did, what we learned at Societe Generale
Adrien Blind
 
Introduction to Unikernels at first Paris Unikernels meetup
Adrien Blind
 
Docker networking basics & coupling with Software Defined Networks
Adrien Blind
 
Ad

Similar to Advanced Task Scheduling with Amazon ECS - Julien Simon (18)

PDF
Advanced Task Scheduling with Amazon ECS (June 2017)
Julien SIMON
 
PDF
Advanced Task Scheduling with Amazon ECS
Julien SIMON
 
PPTX
Advanced Scheduling with Amazon ECS (September 2017)
Julien SIMON
 
PPTX
Weaveworks at AWS re:Invent 2016: Operations Management with Amazon ECS
Weaveworks
 
PDF
AWS reinvent 2019 recap - Riyadh - Containers and Serverless - Paul Maddox
AWS Riyadh User Group
 
PDF
Docker clusters on AWS with Amazon ECS and Kubernetes
Julien SIMON
 
PDF
"AWS Fargate: Containerization meets Serverless" at AWS User Group Cologne 20...
Vadym Kazulkin
 
PDF
Running Docker Containers on AWS
Vladimir Simek
 
PDF
A 60-minute tour of AWS Compute (November 2016)
Julien SIMON
 
PDF
Amazon ECS (March 2016)
Julien SIMON
 
PDF
DCEU 18: Use Cases and Practical Solutions for Docker Container Storage on Sw...
Docker, Inc.
 
PDF
Getting started with Amazon ECS
Ioannis Polyzos
 
PPTX
.NET Developer Days - So many Docker platforms, so little time...
Michele Leroux Bustamante
 
PDF
From Docker Straight to AWS
DevOps.com
 
PDF
Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila
 
PDF
Deliver Docker Containers Continuously on AWS - QCon 2017
Philipp Garbe
 
PPTX
CI/CD on pure AWS
Andrey Trubitsyn
 
PDF
ECS and ECR deep dive
Shiva Narayanaswamy
 
Advanced Task Scheduling with Amazon ECS (June 2017)
Julien SIMON
 
Advanced Task Scheduling with Amazon ECS
Julien SIMON
 
Advanced Scheduling with Amazon ECS (September 2017)
Julien SIMON
 
Weaveworks at AWS re:Invent 2016: Operations Management with Amazon ECS
Weaveworks
 
AWS reinvent 2019 recap - Riyadh - Containers and Serverless - Paul Maddox
AWS Riyadh User Group
 
Docker clusters on AWS with Amazon ECS and Kubernetes
Julien SIMON
 
"AWS Fargate: Containerization meets Serverless" at AWS User Group Cologne 20...
Vadym Kazulkin
 
Running Docker Containers on AWS
Vladimir Simek
 
A 60-minute tour of AWS Compute (November 2016)
Julien SIMON
 
Amazon ECS (March 2016)
Julien SIMON
 
DCEU 18: Use Cases and Practical Solutions for Docker Container Storage on Sw...
Docker, Inc.
 
Getting started with Amazon ECS
Ioannis Polyzos
 
.NET Developer Days - So many Docker platforms, so little time...
Michele Leroux Bustamante
 
From Docker Straight to AWS
DevOps.com
 
Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila
 
Deliver Docker Containers Continuously on AWS - QCon 2017
Philipp Garbe
 
CI/CD on pure AWS
Andrey Trubitsyn
 
ECS and ECR deep dive
Shiva Narayanaswamy
 
Ad

Recently uploaded (20)

PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PDF
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 

Advanced Task Scheduling with Amazon ECS - Julien Simon

  • 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Julien Simon Principal Technical Evangelist, AWS @julsimon Advanced Task Scheduling with Amazon ECS
  • 2. Docker on Amazon Web Services Amazon EC2 Container Service (ECS) • https://aws.amazon.com/ecs/ • Launched in 04/2015 • No additional charge Amazon EC2 Container Registry (ECR) • https://aws.amazon.com/ecr/ • Launched in 12/2015 • Free tier: 500MB / month for a year • $0.10 / GB / month + outgoing traffic Both services are available in US, EU and APAC
  • 7. The problem Given a certain amount of computing power and memory, how can we best manage an arbitrary number of apps running in Docker containers? http://tidalseven.com
  • 8. Amazon ECS: Under the Hood ALB ALB AZ 1 AZ 2 user / scheduler https://github.com/aws/amazon-ecs-agenthttp://www.allthingsdistributed.com/2015/07/under-the-hood-of-the-amazon-ec2-container-service.html
  • 9. Scheduling on ECS: two options so far 1. Let ECS handle scheduling through Services • Task Definition • ECS transcription of the Docker Compose file • Versioning • cpu_shares, mem_limit • Number of desired containers 2. Implement a custom scheduler with the ECS API • Describe cluster state • Select a specific ECS instance according to custom logic • Run task on this instance • Coursera use case: www.youtube.com/watch?v=a45J6xAGUvA
  • 11. Placement Engine: giving developers more control ALB ALB AZ 1 AZ 2 user / scheduler Placement Engine Constraints & Strategies
  • 12. Placement Constraints Name Example AMI ID attribute:ecs.ami-id == ami-eca289fb Availability Zone attribute:ecs.availability-zone == us-east-1a Instance Type attribute:ecs.instance-type == t2.small Distinct Instances type=“distinctInstance” Custom attribute:stack == prod
  • 13. Example: Constraint on Instance Family/Type
  • 14. Example: Constraint on Availability Zone
  • 16. Placement Strategies Binpacking Spread Affinity Distinct Instance
  • 17. Placement Strategy Chaining Spread tasks across Zones and Binpack within each Zone
  • 19. Anatomy of Task Placement Cluster Constraints Custom Constraints Placement Strategies Apply Filter Satisfy CPU, memory, and port requirements Filter for location, instance-type, AMI, or custom attribute constraints Identify instances that meet spread or binpack placement strategy Select final container instances for placement
  • 20. g2.2xlarge t2.small g2.2xlarge g2.2xlarge Placement: Targeting Instance Type
  • 21. g2.2xlarge t2.small t2.micro t2.medium t2.medium t2.small g2.2xlarge t2.small t2.small t2.medium us-east-1aus-east-1d Placement: Targeting Instance Type & Zone
  • 22. g2.2xlarge t2.small t2.micro t2.medium t2.medium t2.small g2.2xlarge t2.small us-east-1aus-east-1d g2.2xlarge t2.medium t2.micro t2.small us-east-1c Placement: Availability Zone Spread
  • 23. g2.2xlarge t2.small t2.micro t2.medium t2.medium t2.small g2.2xlarge t2.small us-east-1aus-east-1d g2.2xlarge t2.medium t2.micro t2.small us-east-1c Placement: Spread across Zone and Binpack
  • 24. g2.2xlarge t2.small t2.micro t2.medium t2.medium t2.small g2.2xlarge t2.small us-east-1aus-east-1d g2.2xlarge t2.medium t2.micro t2.small us-east-1c Placement: Affinity and Anti-Affinity
  • 26. t2.medium t2.small t2.small us-east-1aus-east-1d t2.medium t2.micro t2.small us-east-1c Placement: Multiple Services on a Cluster
  • 27. t2.medium g2.2xlarge t2.micro t2.small t2.small t2.small g2.2xlarge t2.small t2.small t2.small g2.2xlarge t2.small Placement: Services – Distinct Instances
  • 29. Amazon ECS: Under the Hood ALB ALB AZ 1 AZ 2 user / scheduler Placement Engine Event Stream
  • 31. Handling ECS events with Blox scheduler cluster state service https://blox.github.io/
  • 32. Amazon ECS: Under the Hood ALB ALB AZ 1 AZ 2 user / scheduler Scheduler Cluster State Service Placement Engine Event Stream
  • 33. t2.small t2.small t2.small Blox: Daemon Scheduler t2.small t2.small t2.small scheduler cluster state service t2.small t2.small t2.small
  • 35. Creating Clusters Create an ECS cluster for Blox CF template: https://github.com/blox/blox/blob/dev/deploy/aws/conf/cloudformation_template.json à CloudWatch Event Rule + SQS queue à 3 containers: Daemon Scheduler + Cluster State Service + etcd à REST API exposing the Daemon Scheduler API Create another ECS cluster managed by Blox $ ecs-cli configure --cluster WebCluster $ ecs-cli up --keypair admin --capability-iam --size 3 --instance-type t2.micro Invoke the scheduler API ‘demo-cli’ tool: https://github.com/blox/blox/tree/dev/deploy/demo-cli
  • 36. Listing Task Definitions Grab the ARN for an nginx Task Definition, which the Daemon Scheduler will manage on ‘WebCluster’. $ ./list-task-definitions.py --region eu-central-1 == Blox Demo CLI - List Task Definitions == { "taskDefinitionArns": [ "arn:aws:ecs:eu-central-1:ACCOUNT:task-definition/BloxFramework:2", "arn:aws:ecs:eu-central-1:ACCOUNT:task-definition/nginx:1", "arn:aws:ecs:eu-central-1:ACCOUNT:task-definition/nginx:2" ] }
  • 37. Creating an Environment $ ./blox-create-environment.py --environment WebEnvironment --cluster WebCluster --task-definition "arn:aws:ecs:eu-central-1:ACCOUNT:task- definition/nginx:2" --stack Blox --apigateway --region eu-central-1 == Blox Demo CLI - Create Blox Environment == HTTP Response Code: 200 { "taskDefinition": "arn:aws:ecs:eu-central-1:ACCOUNT:task-definition/nginx:2", "deploymentToken": "17248257-08ec-4438-888f-e0ac28397653", "health": "healthy", "name": "WebEnvironment", "instanceGroup": { "cluster": "arn:aws:ecs:eu-central-1:ACCOUNT:cluster/WebCluster" } }
  • 38. Listing Environments $ ./blox-list-environments.py --stack Blox --apigateway --region eu-central-1 == Blox Demo CLI - List Blox Environments == HTTP Response Code: 200 { "items": [ { "taskDefinition": "arn:aws:ecs:eu-central-1:ACCOUNT:task-definition/nginx:2", "deploymentToken": "17248257-08ec-4438-888f-e0ac28397653", "health": "healthy", "name": "WebEnvironment", "instanceGroup": { "cluster": "arn:aws:ecs:eu-central-1:ACCOUNT:cluster/WebCluster" } } ] }
  • 39. Creating a Deployment $ ./blox-create-deployment.py --environment WebEnvironment --deployment-token "17248257-08ec-4438-888f-e0ac28397653" --stack Blox --apigateway --region eu-central-1 == Blox Demo CLI - Create Blox Deployment == HTTP Response Code: 200 { "status": "pending", "environmentName": "WebEnvironment", "id": "7a05ea99-27a9-4339-a7a6-f4120065aea3", "failedInstances": [], "taskDefinition": "arn:aws:ecs:eu-central-1:613904931467:task-definition/nginx:2” }
  • 40. Listing Deployments $ ./blox-list-deployments.py --environment WebEnvironment --stack Blox --apigateway --region eu-central-1 == Blox Demo CLI - List Blox Deployments == HTTP Response Code: 200 { "items": [ { "status": "completed", "environmentName": "WebEnvironment", "id": "7a05ea99-27a9-4339-a7a6-f4120065aea3", "failedInstances": [], "taskDefinition": "arn:aws:ecs:eu-central-1:ACCOUNT:task-definition/nginx:2" } ] }
  • 41. Scaling a Deployment $ ecs-cli ps Name State Ports TaskDefinition 26313cbe-d929-49de-9cc3-873bf5f32a91/nginx RUNNING nginx:2 98442432-fd5c-434d-b93c-0737bd06aaab/nginx RUNNING nginx:2 ce9bf217-4b34-4f31-9c7b-a8c3402f1ffd/nginx RUNNING nginx:2 $ ecs-cli scale --size 4 --capability-iam $ ecs-cli ps Name State Ports TaskDefinition 26313cbe-d929-49de-9cc3-873bf5f32a91/nginx RUNNING nginx:2 98442432-fd5c-434d-b93c-0737bd06aaab/nginx RUNNING nginx:2 c404ac9a-0948-4cc8-b5b0-2238ccdf4035/nginx RUNNING nginx:2 ce9bf217-4b34-4f31-9c7b-a8c3402f1ffd/nginx RUNNING nginx:2
  • 42. Additional resources ECS customers https://www.mapbox.com/blog/switch-to-ecs/ https://segment.com/blog/rebuilding-our-infrastructure/ Tech articles by Werner Vogels, CTO, Amazon.com http://www.allthingsdistributed.com/2014/11/amazon-ec2-container-service.html http://www.allthingsdistributed.com/2015/04/state-management-and-scheduling-with-ecs.html http://www.allthingsdistributed.com/2015/07/under-the-hood-of-the-amazon-ec2-container-service.html Blog articles & videos https://aws.amazon.com/blogs/compute/amazon-ec2-container-service-at-aws-reinvent-2016-wrap-up/ https://aws.amazon.com/blogs/compute/continuous-deployment-to-amazon-ecs-using-aws-codepipeline- aws-codebuild-amazon-ecr-and-aws-cloudformation/
  • 43. Thank you! Julien Simon Principal Technical Evangelist, AWS @julsimon