© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Sascha Möllering, Solutions Architect, @sascha242May 18th, 2017
Deep Dive on Microservices and Docker
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
webserver
.package
Order UI
Order Service
Inventory Service
Shipping Service
OrderUI
Inventory Service
Order Service
Shipping Service
Characteristics of Microservice Architectures
Do one thing wellIndependent
Decentralized
Black box
Polyglot
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 schedulerRun tasks once
Batch jobsRunTask (random) StartTask (placed)
Long-Running Apps
ECS service schedulerHealth managementScale-up and scale-downAZ awareGrouped containers
WatchBot
ECS Cluster
SQSWatcher
Container
Running Tasks
14Data Processing
Services
3500Peak Container
Instances
500 millionCompute Hours
Used in 2016
Amazon ECS: Under the Hood
ALB ALB
AZ 1 AZ 2
user / scheduler
Scheduler
Cluster State Service
Placement Engine
Event Stream
The Twelve-Factor App with Amazon ECS
The Twelve-Factor App
1. Codebase2. Dependencies3. Config
4. Backing Services5. Build, Release Run6. Processes
7. Port Binding8. Concurrency9. Disposability
10. Dev/Prod parity11. Logs12. Admin Processes
https://12factor.net/
Reference Architectures
Example Microservice Architecture on ECS
Amazon ECR
AmazonRDS
Application Load Balancer
ECS Cluster
ECS Cluster
IAM
Amazon API Gateway*
AmazonRoute 53
Amazon CloudWatch
https://github.com/awslabs/ecs-refarch-cloudformation
Private Subnet
Availability Zone Availability Zone
InternetGateway
Public Subnet Public Subnet
Private Subnet
Nat GatewayNat Gateway
AutoScaling GroupContainer InstanceContainer Instance Container InstanceContainer Instance
Application Load Balancer
CloudWatch Logs(container logs)
Amazon ECS Reference Architecture
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
IAM Roles For TasksECS Cluster
EC2 Instance EC2 Instance
TASK A
TASK B
TASK B
AmazonDynamoDB
AmazonS3
AWS CodePipeline
AWSCloudFormation Amazon ECS
Amazon ECRAWS CodeBuild
Developers
1 2
5
3 4
6
7
Continuous Deployment in Amazon ECS
Blue-Green Deployments
TaskTask
Route 53 record set
with weighted routing policy
0%100%
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
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 Group8080 8081
Portal Target Group
Weather Target Group
8000 8001 8002
8080
AmazonRoute 53
ECS Cluster
mydomain.com
mydomain.com mydomain.com/weather
mydomain.com/auth
Consuming Events for Service Discovery
app1-tst à 10.1.0.11db1-tst à 10.1.0.14app2 à 10.1.0.16db2 à 10.1.0.18my-app à 10.1.0.20
websrv1à 10.1.0.1websrv2à 10.1.0.2websrv3à 10.1.0.4app-dev1à 10.1.0.9app-dev2à 10.1.0.5app-dev3à 10.1.0.8
db-devà 10.1.0.19
A Call to Action
Build Learn
Try It out
Deploy
Thank You