NGA1-8_AWS_Moellering_Deep_Dive_on_Microservices_and Docker

1 downloads 130 Views 3MB Size Report
May 18, 2017 - The Twelve-Factor App. 1. Codebase. 2. Dependencies. 3. Config. 4. Backing Services. 5. Build, Release Ru
Deep Dive on Microservices and Docker Sascha Möllering, Solutions Architect, @sascha242 May 18th, 2017

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

What to Expect from the Session • Microservices Architecture • Amazon ECS • The Twelve-Factor App with Amazon ECS

Microservices Architecture

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

Monolithic vs. Microservices

Order UI

OrderUI

Shipping Service

Inventory Service

Order Service

Order Service Inventory Service Shipping Service .package webserver

Characteristics of Microservice Architectures Decentralized

Independent

Black box

Polyglot

Do one thing well

You build it, you run it

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 CloudWatch service for monitoring and logging • Integration with Code* services for continuous integration and delivery (CI/CD)

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

WatchBot

SQS

Watcher Container

Running Tasks

14 3500 500 million ECS Cluster

Data Processing Services

Peak Container Instances

Compute Hours Used in 2016

Amazon ECS: Under the Hood

ALB

AZ 1

ALB

user / scheduler

AZ 2

Scheduler Cluster State Service

Event Stream Placement Engine

The Twelve-Factor App with Amazon ECS

The Twelve-Factor App

1. 2. 3.

4. 5. 6.

Codebase Dependencies Config

Backing Services Build, Release Run Processes

7. 8. 9.

Port Binding Concurrency Disposability

10. Dev/Prod parity 11. Logs 12. Admin Processes

https://12factor.net/

Reference Architectures

Example Microservice Architecture on ECS

Amazon Route 53

ECS Cluster

Amazon RDS

Application Load Balancer

ECS Cluster

Amazon API Gateway*

Amazon ECR

IAM

Amazon CloudWatch

Amazon ECS Reference Architecture

Internet Gateway

Application Load Balancer

Nat Gateway

Public Subnet

Container Instance

Container Instance

Nat Gateway

Public Subnet

AutoScaling Group

Container Instance

Container Instance

Private Subnet

Private Subnet

Availability Zone

Availability Zone

CloudWatch Logs (container logs)

https://github.com/awslabs/ecs-refarch-cloudformation

Automatic Service Scaling Auto Scaling ECS service

Add/Remove ECS tasks

Availability Zone B

Availability Zone A

TASK A

Amazon ECS

TASK C TASK B

Scaling Policies Publish metrics

Amazon CloudWatch Application Load Balancer

IAM Roles For Tasks ECS Cluster

EC2 Instance

EC2 Instance

TASK A TASK B TASK B

Amazon DynamoDB

Amazon S3

Continuous Deployment in Amazon ECS

5

6 AWS CloudFormation

1 Developers

Amazon ECS

2

7 AWS CodePipeline

3

4 AWS CodeBuild

Amazon ECR

Blue-Green Deployments

0% 100% Route 53 record set with weighted routing policy

Task

Task

Secrets Management

EC2 Instance

EC2 Instance

•prod.app1.db-pass •general.license-code •prod.app2.user-name

TASK A

TASK B TASK B EC2 System Manager – Parameter Store

ECS Cluster

Service Discovery with Route 53 and Application Load Balancers mydomain.com

mydomain.com/weather

mydomain.com

Application Load Balancer

mydomain.com/auth

i-aaa

i-bbb

8081 8080 oAuth Target Group

i-ccc 8080 Weather Target Group

i-aaa

i-bbb

i-ccc

8000

8001

8002

Portal Target Group ECS Cluster

Amazon Route 53

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 db-devà 10.1.0.19 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

A Call to Action

Try It out

Build

Learn

Deploy

Thank You