Top Banner
©2015, Amazon Web Services, Inc. or its affiliates. All rights reserved Amazon EC2 Container Service: Manage Docker-Enabled Apps in EC2 Ian Massingham AWS Technical Evangelist @IanMmmm
53
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Amazon ECS

©2015,  Amazon  Web  Services,  Inc.  or  its  affiliates.  All  rights  reserved

Amazon EC2 Container Service: Manage Docker-Enabled Apps in EC2

Ian Massingham AWS Technical Evangelist

@IanMmmm

Page 2: Amazon ECS

Agenda

Containers

EC2 Container Service

Common patterns

Demo

Q&A

Page 3: Amazon ECS

Containers

Page 4: Amazon ECS

What are containers?

OS virtualization

Process isolation

Automation

Images Server

Guest OS

Bins/Libs Bins/Libs

App2 App1

Page 5: Amazon ECS

Container advantages

Portable

Server

Guest OS

Bins/Libs Bins/Libs

App2 App1

Page 6: Amazon ECS

Container advantages

Flexible

Server

Guest OS

Bins/Libs Bins/Libs

App2 App1

Page 7: Amazon ECS

Container advantages

Fast

Server

Guest OS

Bins/Libs Bins/Libs

App2 App1

Page 8: Amazon ECS

Container advantages

Efficient

Server

Guest OS

Bins/Libs Bins/Libs

App2 App1

Page 9: Amazon ECS

A container pipeline IT Operations

Base Image

Patches Utilities

Page 10: Amazon ECS

A container pipeline IT Operations

Base Image

Patches Utilities

Ruby

Redis

Logger

Page 11: Amazon ECS

A container pipeline IT Operations Developer

Base Image

Patches Utilities

Ruby

Redis

Logger

App

Page 12: Amazon ECS

A container pipeline

Base Image

Patches Utilities

Ruby

Redis

Logger

App

IT Operations Developer

Page 13: Amazon ECS

Server

Guest OS

Bins/Libs Bins/Libs

App2 App1

Page 14: Amazon ECS
Page 15: Amazon ECS

EC2 Container Service Benefits

Page 16: Amazon ECS

Easily manage clusters for any scale

Nothing to run

Complete state

Control and monitoring

Scale

Page 17: Amazon ECS

Flexible container placement

Applications

Batch jobs

Multiple schedulers

Page 18: Amazon ECS

Designed for use with other AWS services

Elastic Load Balancing Amazon Elastic Block Store

Amazon Virtual Private Cloud AWS Identity and Access Management

AWS CloudTrail

Page 19: Amazon ECS

Extensible

Comprehensive APIs

Open source agent

Custom schedulers

Page 20: Amazon ECS

Common Patterns

Page 21: Amazon ECS

Pattern 1: services and applications

Simple to model

Decompose to smaller (micro) services

Blue / green deployments

Page 22: Amazon ECS

Pattern 2: batch jobs

Share pools of resources

APIs provide cluster state

Auto Scaling, Spot, Reserved Instances

Page 23: Amazon ECS

EC2 Container Service terminology

Page 24: Amazon ECS

Amazon EC2 instances

Docker daemon

Amazon ECS agent

Key components: container instances

https://github.com/aws/amazon-ecs-agent

Page 25: Amazon ECS

Regional

Resource pool

Grouping of container instances

Start empty, dynamically scalable

Key components: clusters

Page 26: Amazon ECS

Key components: task definitions

Volume Definitions

Container Definitions

Page 27: Amazon ECS

Key components: task definitions

Shared Data Volume

PHP App Time of day App

Page 28: Amazon ECS

Key components: task definitions

Container Instance

Schedule

Shared Data Volume

PHP App Time of day App

Shared Data Volume

PHP App

Time of day App

Page 29: Amazon ECS

Key components: task definitions { "environment": [], "name": "simple-demo", "image": "my-demo", "cpu": 10, "memory": 500, "portMappings": [ { "containerPort": 80, "hostPort": 80 } ], "mountPoints": [ { "sourceVolume": "my-vol", "containerPath": "/var/www/my-vol" } ], "entryPoint": [ "/usr/sbin/apache2", "-D", "FOREGROUND" ], "essential": true },

{ "name": "busybox", "image": "busybox", "cpu": 10, "memory": 500, "volumesFrom": [ { "sourceContainer": "simple-demo" } ], "entryPoint": [ "sh", "-c" ], "command": [ "/bin/sh -c \"while true; do /bin/date > /var/www/my-vol/date; sleep 1; done\"" ], "essential": false }

Page 30: Amazon ECS

{ "environment": [], "name": "simple-demo", "image": "amazon/amazon-ecs-sample", "cpu": 10, "memory": 500, "portMappings": [ { "containerPort": 80, "hostPort": 80 } ], "mountPoints": [ { "sourceVolume": "my-vol", "containerPath": "/var/www/my-vol" } ], "entryPoint": [ "/usr/sbin/apache2", "-D", "FOREGROUND" ], "essential": true },

Key components: task definitions [ { "image": "mysql", "name": "db", "cpu": 10, "memory": 500, "essential": true, "entryPoint": [ "/entrypoint.sh" ], "environment": [ { "name": "MYSQL_ROOT_PASSWORD", "value": "pass" } ], "portMappings": [] }]

Essential to our task

Create and mount volumes

Expose port 80 in container to port 80 on host

10 CPU units (1024 is full CPU), 500 megabytes of memory

Page 31: Amazon ECS

{ "name": "busybox", "image": "busybox", "cpu": 10, "memory": 500, "volumesFrom": [ { "sourceContainer": "simple-demo" } ], "entryPoint": [ "sh", "-c" ], "command": [ "/bin/sh -c \"while true; do /bin/date > /var/www/my-vol/date; sleep 1; done\"" ], "essential": false }

Key components: task definitions [ { "image": "tutum/wordpress-stackable", "name": "wordpress", "cpu": 10, "memory": 500, "essential": true, "links": [ "db" ], "entryPoint": [ "/bin/sh", "-c" ], "environment": [ … ], "portMappings": [ { "containerPort": 80, "hostPort": 80 } ] }, ]

From Docker Hub

Mount volume from other container

Command to exec

Page 32: Amazon ECS

Unit of work

Grouping of related containers

Run on container instances

Key components: tasks

Page 33: Amazon ECS

Key components: run a task

Good for short-lived containers, for example batch jobs

Page 34: Amazon ECS

Key components: create a service

Good for long-running applications and services

Page 35: Amazon ECS

Microservices and elastic resource pools with ECS

Boyan Dimitrov, Platform Automation Lead @ Hailo @nathariel

Page 36: Amazon ECS
Page 37: Amazon ECS

Microservices intro

•  Discovery •  Configuration •  A/B testing capabilities •  Monitoring & Instrumentation •  … and much more

Each service (at Hailo) gets for free:

Service  B  

Service  A  

Service  C  

Service  E  

Service  D  

Small, self-contained units of execution with well defined API Built around business capabilities or domain objects Responsible for one thing and one thing only Fully automated lifecycle

AWS Summits 2015

Monolith  App  

Page 38: Amazon ECS

What do we have

AWS Summits 2015

•  Microservices ecosystem based on Go

•  Designed specifically for the cloud – different building blocks and components will constantly be in flux, broken or unavailable

•  1000+ AWS instances spanning multiple regions

•  200+ services in production

 

Page 39: Amazon ECS

Service interactions – not as scary as it looks!

AWS Summits 2015

Page 40: Amazon ECS

Service deployment at present

Main goals: Reliability, Ease of Use, Resource Efficiency

AWS Summits 2015

•  Each service is decoupled from the rest and deployed individually

•  We run multiple services on the same instance

•  We rely on auto scaling groups for organizing and scaling our workload

•  We use static partitioning to match a service to an auto scaling group

•  An automated deployment system takes care of all service lifecycle details

Page 41: Amazon ECS

Provisioning Service

Provisioning Service

CI Pipeline

Amazon S3

Provisioning Manager

Provisioning Service

Docker Registry

Deployment overview and our journey towards containers

Instance Instance

Process Container

Auto Scaling Group Auto Scaling Group

Page 42: Amazon ECS

How hard is to deploy a service?

service name version

auto scaling group

AWS Summits 2015

Page 43: Amazon ECS

Is this good enough?

Main goals: Reliability, Ease of Use, Resource Efficiency

service name version

auto scaling group How do I figure this one out? Would my service live there forever? What if my team owns 20+ services ?

As a developer:

AWS Summits 2015

Page 44: Amazon ECS

Provisioning Service

What about resource efficiency?

35% Utilization

85% Utilization

Auto Scaling Group A

Auto Scaling Group B

AZ eu-west-1a AZ eu-west-1c AZ eu-west-1b

instance instance instance instance instance instance

instance instance instance

Main goals: Reliability, Ease of Use, Resource Efficiency

AWS Summits 2015

Page 45: Amazon ECS

Challenges

AWS Summits 2015

•  Our overall utilization across the services auto scaling groups is between 25% and 50%

•  Performance of individual services is way more complex than simple CPU and memory calculations. Accumulated interference on the instance needs to be accounted for

•  Static partitioning of services is hard and non scalable

•  Our developers should not care about service placement or infrastructure specifics!

 

Page 46: Amazon ECS

So what do we want?

Elastic resource pool

75-80% Utilization

eu-west-1a eu-west-1b eu-west-1c

One word – such difference!  Main goals: Reliability, Ease of Use, Resource Efficiency

instance   instance   instance   instance   instance   instance  

Page 47: Amazon ECS

Our solution – cluster management on top of an elastic resource pool

Elastic Resource Pool

ECS Agent ECS Agent ECS Agent ECS Agent ECS Agent ECS Agent

QoS Scheduler

eu-west-1a eu-west-1b eu-west-1c

AWS Cloud Provider

ECS Cluster Manager

instance   instance   instance   instance   instance   instance  

Page 48: Amazon ECS

Why ECS?

AWS Summits 2015

•  It is a managed service!

•  It is great for storing and enforcing task state

•  Designed with custom schedulers in mind

•  The agent code is available on a public GitHub repo and … it is in GO!

•  Easy to integrate with other AWS services

 

Page 49: Amazon ECS

Why building our own scheduler?

AWS Summits 2015

•  Service Priority

•  Service specific runtime metrics

•  Interference

•  Cloud awareness ( availability zones, pool elasticity…)

Running services in a pay as you go fashion will soon be a reality as much as todays on demand compute

We want a cloud-native scheduler that is aware of the cloud specifics and our microservices ecosystem:

Page 50: Amazon ECS

{ “service”: “Foo” ”minCPU": 10, ”minMemory": 500, “minInstances”: 3, “Priority”: “Default”}  

{ “service”: “Baz” ”minCPU": 50, ”minMemory": 1500, “minInstances”: 3, “Priority”: “Critical”}  

Take Service Priority as an example

AWS Summits 2015

Page 51: Amazon ECS

t0

t1 XStar6ng  t2

Service criticality ma#ers when resources are constrained

AWS Summits 2015

instance   instance   instance  

instance   instance   instance  

instance  instance   instance  

instance   instance   instance  

t3

Page 52: Amazon ECS

Thanks!

@nathariel [email protected]

@HailoTech facebook.com/HailoUK

Use Promo Code AWS10 for £10 off your ride home

Page 53: Amazon ECS

LONDON