Top Banner
Microservices Unleashed with Containers and ECS Yaniv Donenfeld, Solutions Architect
46

Micrsoservices unleashed with containers and ECS

Jan 23, 2018

Download

Technology

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: Micrsoservices unleashed with containers and ECS

Microservices UnleashedwithContainersandECSYaniv Donenfeld,SolutionsArchitect

Page 2: Micrsoservices unleashed with containers and ECS

Agenda

• Evolution of computing

• What is Amazon EC2 Container Service?

• Overcoming micro-services challenges

Page 3: Micrsoservices unleashed with containers and ECS

Scaling Applications

Page 4: Micrsoservices unleashed with containers and ECS

Order UI User UI Shipping UI

Order Service

User Service

Shipping Service

Data Access

Page 5: Micrsoservices unleashed with containers and ECS
Page 6: Micrsoservices unleashed with containers and ECS

Order UI User UI Shipping UI

Order Service

User Service

Shipping Service

Page 7: Micrsoservices unleashed with containers and ECS

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 8: Micrsoservices unleashed with containers and ECS
Page 9: Micrsoservices unleashed with containers and ECS

What are Containers?

Page 10: Micrsoservices unleashed with containers and ECS

What are Containers?

container

Page 11: Micrsoservices unleashed with containers and ECS

What is Docker?

Docker container

• Declarative modeling

• Packaging

Page 12: Micrsoservices unleashed with containers and ECS

What is Docker?

• Portable

• Flexible

• Fast

• Efficient

Page 13: Micrsoservices unleashed with containers and ECS

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 14: Micrsoservices unleashed with containers and ECS

Server

Guest OS

Bins/Libs Bins/Libs

App2App1

Managing One Host is Straightforward

Page 15: Micrsoservices unleashed with containers and ECS

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 16: Micrsoservices unleashed with containers and ECS

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 17: Micrsoservices unleashed with containers and ECS

Docker

Task

Container Instance

Amazon ECS

Container

ECS Agent

ELB

Internet

ELB

User / Scheduler

API

Cluster Management Engine

Task Container

Docker

Task

Container Instance

Container

ECS Agent

Task Container

Docker

Task

Container Instance

Container

ECS Agent

Task Container

AZ 1 AZ 2

Key/Value Store

Agent Communication Service

Page 18: Micrsoservices unleashed with containers and ECS

Docker

Task

Container Instance

Amazon ECS

Container

ECS Agent

ELB

Internet

ELB

User / Scheduler

API

Cluster Management Engine

Task Container

Docker

Task

Container Instance

Container

ECS Agent

Task Container

Docker

Task

Container Instance

Container

ECS Agent

Task Container

AZ 1 AZ 2

Key/Value Store

Agent Communication Service

Page 19: Micrsoservices unleashed with containers and ECS
Page 20: Micrsoservices unleashed with containers and ECS
Page 21: Micrsoservices unleashed with containers and ECS
Page 22: Micrsoservices unleashed with containers and ECS

What are Microservices Challenges?

• Resource and state management

• Monitoring

• Deployment

• Service discovery

Page 23: Micrsoservices unleashed with containers and ECS

• 36,000,000 users

• 35 container instances running 450 containers

• 400,000 new users a day during BTS

Page 24: Micrsoservices unleashed with containers and ECS

What are Microservices Challenges?

• Resource and state management

• Monitoring

• Deployment

• Service discovery

Page 25: Micrsoservices unleashed with containers and ECS

Monitoring with Amazon CloudWatch

Metric data sent to CloudWatch in 1-minute periods and recorded for a period of two weeksAvailable metrics: CPUReservation, MemoryReservation, CPUUtilization, MemoryUtilizationAvailable dimensions: ClusterName, ServiceName

Page 26: Micrsoservices unleashed with containers and ECS

Monitoring with Amazon CloudWatch

Page 27: Micrsoservices unleashed with containers and ECS

Monitoring with Amazon CloudWatch

Use the CloudWatch monitoring scripts to monitor additional metrics: e.g., disk space

# Edit crontab

> crontab -e

# Add command to report disk space utilization to CloudWatch every five minutes

*/5 * * * * <path_to>/mon-put-instance-data.pl --disk-space-util --disk-space-used --disk-space-avail --disk-path=/ --from-cron

Page 28: Micrsoservices unleashed with containers and ECS

Monitoring Amazon ECS with Datadog

Page 29: Micrsoservices unleashed with containers and ECS

What are Microservices Challenges?

• Resource and state management

• Monitoring

• Deployment

• Service discovery

Page 30: Micrsoservices unleashed with containers and ECS

Scheduling Containers on ECS

Batch Jobs

ECS Task schedulerRun tasks once

Batch jobsRunTask (auto-placed)

StartTask (placed)

Long-Running Apps

ECS Service schedulerHealth managementScale-up and scale-downAZ awareGrouped Containers

Page 31: Micrsoservices unleashed with containers and ECS

Long-running app: Deploy using the least space

minimumHealthyPercent = 50%, maximumPercent = 100%

Page 32: Micrsoservices unleashed with containers and ECS

Long-running App: Deploy quickly without reducing service capacity

minimumHealthyPercent = 100%, maximumPercent = 200%

Page 33: Micrsoservices unleashed with containers and ECS

Scheduling Containers: Long-running App

Blue-Green Deployments

• Define two ECS services• Each service is associated w/ ELB• Both ELBs in Route 53 record set

with weighted routing policy, 100% Primary, 0% Secondary

• Deploy to Blue or Green service and switch weights

TaskTask

Route 53 record set

with weighted routing policy

0%100%

Page 34: Micrsoservices unleashed with containers and ECS

Demo

Page 35: Micrsoservices unleashed with containers and ECS

Demo

TaskTask

Page 36: Micrsoservices unleashed with containers and ECS

Demo

TaskTask

Page 37: Micrsoservices unleashed with containers and ECS

Demo

TaskTask

Page 38: Micrsoservices unleashed with containers and ECS

Demo

TaskTask

Page 39: Micrsoservices unleashed with containers and ECS

Demo

TaskTask

Task

Page 40: Micrsoservices unleashed with containers and ECS

What are Microservices Challenges?

• Resource and state management

• Monitoring

• Deployment

• Service discovery

Page 41: Micrsoservices unleashed with containers and ECS

Service Discovery with ECS Services & Route 53

Page 42: Micrsoservices unleashed with containers and ECS

• Wrapp delivers personal offers and rewards based on where you shop, dine and the brands

you follow.

• Infrastructure:

• 13 ECS Clusters

• 50+ Instances

• 90+ Services

• Technology Stack:

• Operating System – Ubunu

• Consul, Registrator, AWS(EC2, ECS, Lambda), Docker, HAProxy

• Languages - Go, Python, Java

Wrapp: Service Discovery with ELB, Consul and HAProxy

Page 43: Micrsoservices unleashed with containers and ECS

api

8080

Consulserver-b

Consul server-a

Consulserver-c

users

8082

auth

8081

users

8082

Registrator Registrator Registrator

ConsulAgentConsulAgentConsulAgent

Key/value store

Servicecatalog

10.0.0.1 10.0.0.2 10.0.0.3

HAConsulCluster

Service Discovery @ Wrapp

Page 44: Micrsoservices unleashed with containers and ECS

Service Discovery with Weaveworks

• DNS interface for cross-host container communication

• Gossip protocol to share grouped updates

• Overlay network between hosts

Page 45: Micrsoservices unleashed with containers and ECS