You have heard how containers are great for running microservices, but running and managing large scale applications with microservices architectures is hard and often requires operating complex container management infrastructure. So what exactly is needed to get microservices to run in production at scale?
In this session, we will explore the reasoning and concepts behind microservices and how containers simplify building microservices based applications, and we will walk through a number of patterns used by our customers to run their microservices platforms. We will also dive deep into some of the challenges of running microservices, such as load balancing, service discovery, and secrets management, and we’ll see how Amazon EC2 Container Service (ECS) can help address them. We will also demo how you can easily deploy complex microservices applications using Amazon ECS.
4. 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
6. Characteristics of microservice architectures
Do one
thing wellIndependent
Decentralized
Black box
Polyglot
You build it, you run it
7. Microservices on EC2
Auto Scaling group
Elastic
Load
Balancer
EC2 instance EC2 instance EC2 instance
AWS Elastic
Beanstalk
Database
8. Elastic Beanstalk
Your code
HTTP server
Application server
Language interpreter
Operating system
Host
Elastic Beanstalk configures
each EC2 instance in your
environment with the
components necessary to run
applications for the selected
platform. No more worrying
about logging into instances to
install and configure your
application stack.
Focus on building your
application
Provided by you
Provided and managed by Elastic Beanstalk
Including Docker support…
9. Managed
API Gateway serverless approach
InternetMobile
apps
AWS
Lambda
functions
AWS
API Gateway
cache
Endpoints on
Amazon EC2
Any other
publicly
accessible
endpoint
Amazon
CloudWatch
Amazon
CloudFront
API
Gateway
API Gateway
Other AWS
services
AWS
Lambda
functions
10. Amazon API Gateway
Create, publish, maintain, monitor and
secure RESTful APIs
Powered by our content delivery
network via 60 global edge locations
Provides DDoS protection and
throttling capabilities
Multiple API stages which you define
(e.g., dev, test, prod)
AWS Lambda
Amazon API
Gateway
Amazon EC2
AWS API
On-prem server
11. 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 for
monitoring and logging
• Integration with Code* services for
continuous integration and delivery (CI/CD)
12. 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
18. New placement constraints and attributes
Name Example
AMI ID attribute:ecs.ami-id == ami-eca289fb
Availability Zone attribute:ecs.availability-zone == us-east-1a
Instance Type attribute:ecs.instance-type == t2.small
Distinct Instances type=“distinctInstance”
Custom attribute:stack == prod
19. Anatomy of task placement
Cluster Constraints
Custom Constraints
Placement Strategies
Apply Filter
Satisfy CPU, memory, and port requirements
Filter for location, instance-type, AMI, or custom
attribute constraints
Identify instances that meet spread or binpack
placement strategy
Select final container instances for placement
42. Example: Microservice architecture on ECS
Amazon
ECR
Amazon
RDS
Application Load
Balancer
ECS Cluster
ECS Cluster
IAM
Amazon API
Gateway*
Amazon
Route 53
Amazon CloudWatch
43. 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
44. IAM roles for tasks
ECS Cluster
EC2 Instance EC2 Instance
TASK A
TASK B
TASK B
Amazon
DynamoDB
Amazon
S3