Download - Deep Dive on Microservices and Amazon ECS
![Page 1: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/1.jpg)
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Matt McClean, AWS Solutions Architect Igor Serko, Lead Operations Engineer, Lyst
2016-07-07
Deep Dive on Microservices and Amazon ECS
![Page 2: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/2.jpg)
What to Expect from this Session
Microservices: What are They?
Challenges of Microservices
Microservices on Amazon ECS
Customer story: Lyst
![Page 3: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/3.jpg)
What are Microservices?
![Page 4: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/4.jpg)
What are Microservices?
“is 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: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/5.jpg)
Monolithic vs. SOA vs. Microservices
SOA Coarse-grained
Microservices Fine-grained
Monolithic Single unit
![Page 6: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/6.jpg)
Order UI User UI Shipping UI
Order Service
User Service
Shipping Service
Data Access
Monolithic Architecture
![Page 7: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/7.jpg)
Monolithic Architecture – Scaling
![Page 8: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/8.jpg)
Order UI User UI Shipping UI
Order Service
User Service
Shipping Service
Microservices Architecture
![Page 9: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/9.jpg)
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
Microservices Architecture – Scaling
![Page 10: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/10.jpg)
Characteristics of Microservices Architectures
Do one thing well
Independent
Decentralized
Black box
Polyglot
You build it, you run it
![Page 11: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/11.jpg)
Containers are Natural for Services
Simple to model
Any app, any language
Image is the version
Test & deploy same artifact
Stateless servers decrease change risk
![Page 12: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/12.jpg)
What are Microservices Challenges?
Resource and state management
Monitoring
Service discovery
Deployment
![Page 13: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/13.jpg)
What are Microservices Challenges?
Resource and state management
Monitoring
Service discovery
Deployment
![Page 14: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/14.jpg)
Server
Guest OS
Bins/Libs Bins/Libs
App2App1
Managing One Host is Straightforward
![Page 15: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/15.jpg)
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: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/16.jpg)
Amazon EC2 Container Service
![Page 17: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/17.jpg)
Easily Manage Clusters for Any Scale
Nothing to run
Complete state
Control and monitoring
Scale
![Page 18: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/18.jpg)
Scalable
![Page 19: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/19.jpg)
Flexible Container Placement
Applications
Batch jobs
Multiple schedulers
![Page 20: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/20.jpg)
Designed for use with other AWS services
Elastic Load Balancing Amazon Elastic Block Store Amazon Elastic File System Amazon Virtual Private Cloud AWS Identity and Access Management AWS CloudTrail
![Page 21: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/21.jpg)
Clusters
Regional
Resource pool
Grouping of container instances
Start empty, dynamically scalable
![Page 22: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/22.jpg)
Tasks
Unit of work
Grouping of related containers
Run on container instances
![Page 23: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/23.jpg)
Services
Good for long-running applications
Load balance traffic across containers
Automatically recover unhealthy containers
Discover services
![Page 24: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/24.jpg)
What are Microservices Challenges?
Resource and state management
Monitoring
Service discovery
Deployment
![Page 25: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/25.jpg)
Monitoring with Amazon CloudWatch
Metric data sent to CloudWatch in 1-minute periods and recorded for a period of two weeks Available metrics: CPUReservation, MemoryReservation, CPUUtilization, MemoryUtilizationAvailable dimensions: ClusterName, ServiceName
![Page 26: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/26.jpg)
Monitoring with Amazon CloudWatch
![Page 27: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/27.jpg)
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: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/28.jpg)
Monitoring Amazon ECS with Datadog
![Page 29: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/29.jpg)
Monitoring Amazon ECS with Sysdig Cloud
![Page 30: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/30.jpg)
What are Microservices Challenges?
Resource and state management
Monitoring
Service discovery
Deployment
![Page 31: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/31.jpg)
Service Discovery with ECS Services & Route 53
Route 53 private hosted zone Set search path on hosts with DHCP option sets Define ECS services with ELB Create CNAMEs for each ELB
![Page 32: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/32.jpg)
Service Discovery with ECS Services & Route 53
Task
Task TaskTask
ECS service
Application router, e.g.
NGINX
Internal ELB with CNAME, e.g.
api.example.com
Route 53 private zone, e.g.
example.com
![Page 33: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/33.jpg)
Service Discovery with Weaveworks
Overlay network between hosts DNS interface for cross-host container communication Gossip protocol to share grouped updates
![Page 34: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/34.jpg)
Service Discovery with Weaveworks
![Page 35: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/35.jpg)
Service Discovery with Consul
• Distributed Key Value store • Simple interface - DNS or HTTP • Health Checks • Dynamic Configuration Management
![Page 36: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/36.jpg)
Service Discovery with Consul
ECS
Clu
ster
consul-server
ECS Instance
consul-agent
registrator
ECS Instance
Back end 1
Back end 2
consul-agent
registrator
ECS Instance
Front end
ECS
Clu
ster
![Page 37: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/37.jpg)
What are Microservices Challenges?
Resource and state management
Monitoring
Service discovery
Deployment
![Page 38: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/38.jpg)
Scheduling Containers on ECS
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 Zone-aware Grouped containers
![Page 39: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/39.jpg)
Scheduling Containers: Long-running App
Optionally run your service behind a load balancer. ELB currently supports a fixed relationship between the load balancer port and the container instance port. If a task fails the ELB health check, the task is killed and restarted (until service reaches desired capacity).
![Page 40: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/40.jpg)
Scheduling Containers: Long-running App
Update service’s task definition (rolling update) Specify a deployment configuration for your service: • minimumHealthyPercent: lower limit (as a percentage of
the service's desiredCount) of the number of running tasks that must remain running in a service during a deployment.
• maximumPercent: upper limit (as a percentage of the service's desiredCount) of the number of running tasks that can be running in a service during a deployment.
![Page 41: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/41.jpg)
Scheduling Containers: Long-running app
Deploy using the least space: minimumHealthyPercent = 50%, maximumPercent = 100%
![Page 42: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/42.jpg)
Scheduling Containers: Long-running App
Deploy quickly without reducing service capacity: minimumHealthyPercent = 100%, maximumPercent = 200%
![Page 43: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/43.jpg)
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 44: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/44.jpg)
Microservices Development Lifecycle
developers delivery pipelinemicroservices
build pipelinebuild pipeline
build pipeline
build pipelinebuild pipeline
build pipeline
build pipelinebuild pipeline
build pipeline
build pipelinebuild pipeline
build pipeline
build pipelinebuild pipeline
build pipeline
![Page 45: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/45.jpg)
Deployment pipeline for Amazon ECS
https://stelligent.com/2016/06/10/automate-amazon-ec2-container-service-provisioning-and-orchestration-using-cloudformation-and-aws-codepipeline/
![Page 46: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/46.jpg)
ECS CI/CD Partners
![Page 47: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/47.jpg)
Microservices at Lyst
Igor Serko
Lead Operations Engineer
Lyst Ltd
![Page 48: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/48.jpg)
What is Lyst?
Fashion startup
London and New York
Established in 2010
AWS
Python / Django framework
![Page 49: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/49.jpg)
Why Microservices?
Monolith codebase problems
Dependency on ops team
Team growth
Self-sufficient developers
![Page 50: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/50.jpg)
Docker and the 12 factor application
Less stress on platform team
Consistent environments
Moved to Docker early on
Used 12 factor principles
Library dependencies
![Page 51: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/51.jpg)
Splitting the monolith
New projects as microservices
Deployment is an issue
![Page 52: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/52.jpg)
What do we want?
Developers deploy by themselves
Least amount of infrastructure management
Plug and Play
![Page 53: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/53.jpg)
AWS ECS
Released end of 2014
Runs Docker containers
Have to use APIs
Node scaling using EC2 Auto Scaling
ECS Task scaling using Cloudwatch metrics
![Page 54: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/54.jpg)
Empire
Actively developed by Remind
Lightweight
Simple to use
Developer controlled scaling
Provides log streaming
Built on top of AWS ECS
![Page 55: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/55.jpg)
Applications
12 Factor application
Service definition using Procfile
CI builds and pushes Docker images
![Page 56: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/56.jpg)
Production
30 applications
Developers deploying their apps
Service Discovery using ELB
Developers responsible for app health
Faster development cycle
Desired Features
![Page 57: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/57.jpg)
Thank you!
![Page 58: Deep Dive on Microservices and Amazon ECS](https://reader033.vdocuments.net/reader033/viewer/2022042723/58f2cd591a28ab0b138b45af/html5/thumbnails/58.jpg)
Please remember to rate this session under My Agenda on
awssummit.london
@iserko @matthewmcclean