72
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Solutions Architect, Amazon Web Services Japan Containers and the Evolution of Computing Ryosuke Iwanaga July 2016, LinuxCon+ContainerCon Japan

20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Solutions Architect, Amazon Web Services Japan

Containers and the Evolution of ComputingRyosuke Iwanaga

July 2016, LinuxCon+ContainerCon Japan

Page 2: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Scaling Applications

Page 3: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster
Page 4: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster
Page 5: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Order UI User UI Shipping UI

Order Service

User Service

Shipping Service

Page 6: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Order UI User UI UI

Order Service Service Shipping

Service

Order UIOrder UI

User UI UIShipping UI

Order ServiceOrder

ServiceService

ServiceService

ServiceUser

Service

Shipping Service

Page 7: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

What is DevOps?

DevOps = efficiencies that speed up this lifecycle

developers customers

releasetestbuild

plan monitor

delivery pipeline

feedback loop

Software development lifecycle

Page 8: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Monolith development lifecycle

developers

releasetestbuild

delivery pipelineapp

Page 9: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Microservice development lifecycle

developers delivery pipelinesservices

releasetestbuild

releasetestbuild

releasetestbuild

releasetestbuild

releasetestbuild

releasetestbuild

Page 10: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Services

• Not only for "microservices"; • Division, New business, Internal/External, etc.

• There tends to be a lot of "services"• From startup to enterprise

• So many services, so many pipelines/devops

Page 11: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

DevOps reality

Build Test ProductionSource

Application Artifact

All my need is Code…?

Page 12: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

DevOps reality

Build Test ProductionSource

Application Artifact

Provision

Config

Maintain development environment…

Environment difference between dev, test, prod…

Demands for test workload is diverse…

Auto scaling…Node fail...

OK, all my need is everything…

Page 13: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Multiple DevOps Reality

Page 14: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

DevOps difficulty

• Too many things to handle• "Unicorn" person / team

• Too many different pipelines• Services, Languages, Frameworks, Versions, etc.

Page 15: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster
Page 16: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

What are Containers?

OS virtualization

Process isolation

Images

Automation Server

Guest OS

Bins/Libs Bins/Libs

App2App1

Page 17: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Container Advantages

Portable

Flexible

Fast

EfficientServer

Guest OS

Bins/Libs Bins/Libs

App2App1

Page 18: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Containers are Natural for Microservices

Simple to model

Any app, any language

Image is the version

Test & deploy same artifact

Stateless servers decrease change risk

Page 19: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

DevOps with Docker

Build Test ProductionSource

Application Image

Provision

Config

All my need is Code! Yah!

Page 20: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Server

Guest OS

Bins/Libs Bins/Libs

App2App1

Managing One Host is Straightforward

Page 21: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Managing a Fleet is Hard

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

Server

Guest OS

AZ 1 AZ 2

AZ 3

Page 22: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

What is Amazon ECS?

Amazon EC2 Container Service (Amazon ECS) is a highly scalable, high performance container management service. You can use Amazon ECS to schedule the placement of containers across your cluster. You can also integrate your own scheduler or third-party scheduler to meet business or application specific requirements.

Page 23: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Container Management at Any Scale

Nothing to run

Complete state

Control and monitoring

Scale

Page 24: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Flexible Container Placement

Long running applications

Batch jobs

Multiple schedulers

Page 25: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Integration with the AWS Platform

Elastic Load Balancing

Amazon Elastic Block Store

Amazon Virtual Private Cloud

Amazon CloudWatch

AWS Identity and Access Management

AWS CloudTrail

Page 26: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Container Management

Page 27: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

What is a Container Manager?

• Maintains available resources

• Tracks resource changes

• Accepts resource requests

• Guarantees accuracy and consistency

Page 28: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

CPU

Memory

Ports

Disk space

Disk IOPS

Network bandwidth

Resources

Page 29: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

How do you model your applications?

Page 30: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster
Page 31: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

{"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

},

Page 32: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

{"name": "simple-demo","image": "my-demo","cpu": 10,"memory": 500,"portMappings": [

{"containerPort": 80,"hostPort": 80

}],"entryPoint": [

"/usr/sbin/apache2","-D","FOREGROUND"

],"essential": true

},

“Task Definitions”

Page 33: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Tasks

Shared Data Volume

Containers

launchContainer Instance

Volume Definitions

Container Definitions

Page 34: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Schedulers

Page 35: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

What is a Scheduler?

• Determine desired state

• Check against current state

• Perform action

Page 36: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Cluster, Scheduler, Task Scheduler

ManagerCluster

Task Definition

Task

Agent

Page 37: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

ECS Agent

Docker

Task

Container Instance

Container

ECS Agent

Task

Container

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

Page 38: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Instance Registration

register-container-instance --total-resources

[{

“name” : “cpu”,“type” : “integerValue”,“integerValue” : 2048

},…

]

Page 39: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Starting a Task

API

User / Scheduler

StartTask

Page 40: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Starting a Task

API

User / Scheduler

StartTask

Cluster Management Engine

Page 41: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Starting a Task

API

User / Scheduler

StartTask

Cluster Management Engine

Agent Communication

Page 42: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Starting a Task

API

User / Scheduler

StartTask

Cluster Management Engine

Agent Communication

Docker

Container Instance

ECS Agent

TaskContainer

WebSocket

Page 43: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Starting a Task

API

User / Scheduler

StartTask

Cluster Management Engine

Agent Communication

DockerTask

Container Instance

Container

ECS Agent

TaskContainer

SubmitStateChange

Page 44: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Tracking Resource Changes

Page 45: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Terminated Task

API

User / Scheduler

StartTask

Cluster Management Engine

Agent Communication

DockerTask

Container Instance

Container

ECS Agent

SubmitStateChange

Page 46: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Missing Container Instance

API

User / Scheduler

StartTask

Cluster Management Engine

DockerTask

Container Instance

Container

ECS Agent

?

Agent Communication

Page 47: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Terminated Container Instance

API

User / Scheduler

StartTask

Cluster Management Engine

Agent Communication

Termination Notifier

DockerTask

Container Instance

Container

ECS Agent

Page 48: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Guaranteeing Accuracy and Consistency

Page 49: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Amazon ECS Under the Hood

IDN-1 IDN IDN+1 IDN+2 IDN+3 IDN+4 IDN+5

IDN+6

IDN+5

WRITE

READ

Page 50: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Amazon ECS Under the Hood

IDN-1 IDN IDN+1 IDN+2 IDN+3 IDN+4 IDN+5

IDN+6IDN+3

IDN+5IDN+2

WRITE WRITE

READREAD

Page 51: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Scalable

Page 52: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Multiple Schedulers

Page 53: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Amazon ECS: Scheduling• Each scheduler periodically queries the current cluster state

Copy of cluster stateScheduler A Scheduler B

Cluster

Page 54: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Amazon ECS: Scheduling• Each scheduler allocates tasks on the cluster• Each scheduler updates the current cluster state

Run a taskRun a task

Page 55: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Amazon ECS: Scheduling• If the resource is already claimed, the request will be rejected

Run a task on the same resource=> Transactional

Page 56: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Amazon ECS: Scheduling

• Shared state optimistic scheduling• All schedulers can see the current cluster state at all times

Page 57: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Amazon ECS Service Scheduler

Page 58: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

What is a Service?

• Models a long-running application

• Maintains desired state

• Optionally runs behind an Elastic Load Balancing load

balancer

Page 59: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Scheduling Containers: Long-running App

Deploy using the least space:minimumHealthyPercent = 50%, maximumPercent = 100%

Old version New version

Page 60: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Scheduling Containers: Long-running AppDeploy quickly without reducing service capacity: minimumHealthyPercent = 100%, maximumPercent = 200%

Old version New version

Page 61: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Task Auto Scaling

Page 62: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Task Auto Scaling

• Service Scheduler is integrated with Auto Scaling• CloudWatch Alarm => Policy => Modify Desired count

• Useful CloudWatch metrics:• CPU/Memory Utilization per Service

• How much each task consumes reserved resources?• CPU/Memory Utilization per Cluster

• How much actual cluster-wide resources are consumed?• CPU/Memory Reservation per Cluster

• How much cluster-wide resources are reserved?

Page 63: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Monitoring with Amazon CloudWatch Dashboards

Page 64: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Case studies

Page 65: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

“Moving to Amazon ECS significantly improved our service performance. We reduced service response times in the 99th percentile by 50%”

Jason FischlVP of Engineering

Page 66: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

SegmentTo collect customer data in a single hub for later use in analytics, marketing, and for other purposes.

"Switching to Amazon ECS has greatly simplified running a service without needing to worry about provisioning or

availability."

Calvin French-OwenCofounder and Chief Technology Officer

Before• Instance based• Manual setup• Wrong config / Out of sync

After• Easy maintaining, stateless• CI/CD pipeline automated• Focus on developing

https://aws.amazon.com/solutions/case-studies/segment/

Page 67: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

To recap

Page 68: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster
Page 69: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

{"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

},

“Task Definitions”

Page 70: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Scheduler

ManagerCluster

Task Definition

Task

Agent

Page 71: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster
Page 72: 20160714 Containers and the Evolution of …...2016/07/15  · Amazon ECS: Scheduling • Each scheduler allocates tasks on the cluster • Each scheduler updates the current cluster

Thank you!