srv409 deep dive on microservices and docker

50
© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Pierre Steckmeyer, AWS Solutions Architect Will McCutchen, BuzzFeed Chief Refactoring Officer August 14, 2017 Deep Dive on Microservices and Docker

Upload: amazon-web-services

Post on 21-Jan-2018

1.092 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: SRV409 Deep Dive on Microservices and Docker

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

Pierre Steckmeyer, AWS Solutions Architect

Will McCutchen, BuzzFeed Chief Refactoring Officer

August 14, 2017

Deep Dive on Microservices

and Docker

Page 2: SRV409 Deep Dive on Microservices and Docker

What to Expect from the Session

• Microservices Architecture

• Amazon ECS

• The Twelve-Factor App with Amazon ECS

• Task Placement

• BuzzFeed’s story

Page 3: SRV409 Deep Dive on Microservices and Docker

Microservices Architecture

Page 4: SRV409 Deep Dive on Microservices and Docker

What are microservices?

“A software architecture style in which complex

applications are composed of small, independent

processes communicating with each other using

language-agnostic APIs. These services are small, highly

decoupled and focus on doing a small task, facilitating a

modular approach to system-building.” - Wikipedia

https://en.wikipedia.org/wiki/Microservices

Page 5: SRV409 Deep Dive on Microservices and Docker

Monolithic vs. Microservices

webserver

.package

Order UI

Order Service

Inventory

Service

Shipping

Service

OrderUI

Inventory

Service

Order

Service

Shipping

Service

Page 6: SRV409 Deep Dive on Microservices and Docker

Characteristics of Microservice Architectures

Do one

thing wellIndependent

Decentralized

Black box

Polyglot

You build it, you run it

Page 7: SRV409 Deep Dive on Microservices and Docker

Why Amazon ECS

• Fully managed elastic service – You don’t

need to run anything, and the service

scales as your microservices architecture

grows

• Shared state optimistic scheduling

• Integration with Amazon CloudWatch

service for monitoring and logging

• Integration with Code* services for

continuous integration and delivery (CI/CD)

Page 8: SRV409 Deep Dive on Microservices and Docker

Deploying Containers on ECS – Choose a Scheduler

Batch Jobs

ECS task scheduler

Run tasks once

Batch jobs

RunTask (random)

StartTask (placed)

Long-Running Apps

ECS service scheduler

Health management

Scale-up and scale-down

AZ aware

Grouped containers

Page 9: SRV409 Deep Dive on Microservices and Docker

The Twelve-Factor App with

Amazon ECS

Reference Architectures

Page 10: SRV409 Deep Dive on Microservices and Docker

The Twelve-Factor App

1. Codebase

2. Dependencies

3. Config

4. Backing Services

5. Build, Release Run

6. Processes

7. Port Binding

8. Concurrency

9. Disposability

10. Dev/Prod parity

11. Logs

12. Admin Processes

https://12factor.net/

Page 11: SRV409 Deep Dive on Microservices and Docker

Reference Architectures

Page 12: SRV409 Deep Dive on Microservices and Docker

Automatic Service Scaling

Publish metrics

Auto Scaling ECS service

Availability

Zone A

Availability

Zone B

TASK A

Add/Remove ECS

tasks

TASK C

TASK BScaling Policies

Amazon

CloudWatch

Amazon ECS

Application

Load Balancer

Page 13: SRV409 Deep Dive on Microservices and Docker

IAM Roles for Tasks

ECS Cluster

EC2 Instance EC2 Instance

TASK A

TASK B

TASK B

Amazon

DynamoDBAmazon

S3

Page 14: SRV409 Deep Dive on Microservices and Docker

Secrets Management

•prod.app1.db-pass

•general.license-code

•prod.app2.user-name

ECS Cluster

EC2 Instance EC2 Instance

TASK A

TASK B

TASK B

EC2 System Manager –

Parameter Store

Page 15: SRV409 Deep Dive on Microservices and Docker

Continuous Deployment

AWS

CodeCommit AWS

CodePipeline

AWS

CodeBuild

Amazon

ECR

Amazon

ECS

instance

Spot

Instance

AWS

CloudFormation

1. Commit

Code

2. Trigger

Pipeline

3.

Bu

ild

Art

ifact

5.

Up

da

te

Sta

ck

6. Update Service

4. Push Image

Page 16: SRV409 Deep Dive on Microservices and Docker

Blue-Green Deployments (DNS based)

TaskTask

Route 53

record set

with

weighted

routing

policy

0%

100%

Page 17: SRV409 Deep Dive on Microservices and Docker

Blue-Green Deployments (Target Group Switch)

TaskTask

Target

group 1

Target

group 2

Target

group 2Target

group 1

Switch Target

Groups

myproduct.com

Page 18: SRV409 Deep Dive on Microservices and Docker

Service Discovery with Route 53 and Application

Load Balancers

Application Load

Balancer

i-aaa i-bbb i-ccc

i-aaa i-bbb i-ccc

oAuth Target Group

8080 8081

Portal Target Group

Weather Target Group

8000 8001 8002

8080

Amazon

Route 53

ECS Cluster

mydomain.com

mydomain.com mydomain.com/weather

mydomain.com/auth

Page 19: SRV409 Deep Dive on Microservices and Docker

Consuming Events for Service Discovery

app1-tst 10.1.0.11

db1-tst 10.1.0.14

app2 10.1.0.16

db2 10.1.0.18

my-app 10.1.0.20

websrv1 10.1.0.1

websrv2 10.1.0.2

websrv3 10.1.0.4

app-dev1 10.1.0.9

app-dev2 10.1.0.5

app-dev3 10.1.0.8

db-dev 10.1.0.19

Page 20: SRV409 Deep Dive on Microservices and Docker

Task Placement Examples

Page 21: SRV409 Deep Dive on Microservices and Docker

g2.2xlarge t2.small g2.2xlarge g2.2xlarge

Placement: Targeting Instance Type

Page 22: SRV409 Deep Dive on Microservices and Docker

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

Page 23: SRV409 Deep Dive on Microservices and Docker

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

Page 24: SRV409 Deep Dive on Microservices and Docker

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

Page 25: SRV409 Deep Dive on Microservices and Docker

Running a Service

Page 26: SRV409 Deep Dive on Microservices and Docker

Customers

Page 27: SRV409 Deep Dive on Microservices and Docker

Problem:

• A large number of smart phone devices and IoT

devices as of the launch of new flagship

smartphone model launch.

• Integration with existing SmartThings service

• Global development team in 4 locations had to develop more than 60 functional modules.

Solution:

• Microservice Architecture on AWS

• Amazon EC2 Container Service, AWS Lambda, Amazon Aurora, Amazon DynamoDB

Business Benefits:

• “Expect a rich IoT experience with Samsung Connect built on Amazon's robust cloud” – VP Subaek Jang

Samsung Connect Service supports a number of smart

phone devices and IoT devices as of the launch of new

flagship smartphone model launches. AWS service such

as AWS EC2 Container Service, AWS Lambda, Amazon

Aurora and Amazon DynamoDB, Samsung could

successfully develop Samsung Connect application with

more than 60 functional modules by 4 global development

teams in Micro-Service Architecture.

• AWS Seoul Summit Keynote -https://youtu.be/061bsq0jVYU?t=1h16m

Samsung Connec t

Customer case: Samsung Electronics – Samsung Connect

Page 28: SRV409 Deep Dive on Microservices and Docker

IoT Connected

Devices

Event Pipeline

EC2

S3

Galaxy Devices Microservice

Microservice

Microservice

IoT Protocol

Endpoint

ELB/ALB

DynamoDB &

Aurora

Manufacturers

Developers

KMS

CloudHSM

Lambda/

API GW3rd Party Cloud

Admin

CloudWatch

Scale-in/out

Policy

…..

Microservice

Customer case: Samsung Connect Microservices

Page 29: SRV409 Deep Dive on Microservices and Docker

WatchBot

ECS Cluster

SQS

Watcher

Container

Running

Tasks

14Data Processing

Services

3500Peak Container

Instances

500 millionCompute Hours

Used in 2016

Page 30: SRV409 Deep Dive on Microservices and Docker

Building a

platform

on ECS

Page 31: SRV409 Deep Dive on Microservices and Docker
Page 32: SRV409 Deep Dive on Microservices and Docker

● ~400 services currently deployed

● ~80 container instances

● 7 clusters

● 2 regions

● ~16 months in production

● ~180 users

● ~39,000 deploys

Where are we now?

Page 33: SRV409 Deep Dive on Microservices and Docker

How did we get here?

Page 34: SRV409 Deep Dive on Microservices and Docker

How did we get here?

Page 35: SRV409 Deep Dive on Microservices and Docker

How did we get here?

microservices.gif from Justin Duke

(@justinmduke)

Page 36: SRV409 Deep Dive on Microservices and Docker

What we learned

Page 37: SRV409 Deep Dive on Microservices and Docker

Make your development & deployment workflow as frictionless as possible

Page 38: SRV409 Deep Dive on Microservices and Docker

Target abstractions, force consistency

Page 39: SRV409 Deep Dive on Microservices and Docker

Leverage the whole AWS platform

Page 40: SRV409 Deep Dive on Microservices and Docker

Make everything self-service

Page 41: SRV409 Deep Dive on Microservices and Docker

Some challenges

Page 42: SRV409 Deep Dive on Microservices and Docker

Network-level access control and isolation

Page 43: SRV409 Deep Dive on Microservices and Docker

Quickly & safely rolling clusters

Page 44: SRV409 Deep Dive on Microservices and Docker

Sharing ECR registries

Page 45: SRV409 Deep Dive on Microservices and Docker

Efficiency

Page 46: SRV409 Deep Dive on Microservices and Docker

What's next?

Page 47: SRV409 Deep Dive on Microservices and Docker
Page 48: SRV409 Deep Dive on Microservices and Docker

Will McCutchenPlatform Infrastructure

[email protected]

twitter.com/mccutchen

Page 49: SRV409 Deep Dive on Microservices and Docker

Thank You

Page 50: SRV409 Deep Dive on Microservices and Docker

Thank You!