SlideShare una empresa de Scribd logo
1 de 64
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
28.03.2019
S T O C K H O L M
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
S T O C K H O L M
28.03.2019
Breaking the Monolith
Modern Application Design with Containers
and the 12 factors app
Sébastien Stormacq
Technical Evangelist, AWS
@sebsto
M A D 4
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Best Software Architecture Practices
Use declarative formats for setup automation, to minimize time and cost for new
developers joining the project;
Have a clean contract with the underlying operating system, offering maximum
portability between execution environments;
Are suitable for deployment on modern cloud platforms, obviating the need for servers
and systems administration;
Minimize divergence between development and production, enabling continuous
deployment for maximum agility;
And can scale up without significant changes to tooling, architecture, or development
practices.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
The 12 factor application
I. Codebase
One codebase w/ revision control, many deploys
II. Dependencies
Explicitly declare and isolate dependencies
III. Config
Store config in the environment
IV. Backing services
Treat backing services as attached resources
V. Build, release, run
Strictly separate build and run stages
VI. Processes
Execute the app as one or more stateless processes
VII. Port binding
Export services via port binding
VIII. Concurrency
Scale out via the process model
IX. Disposability
Fast startup and graceful shutdown
X. Dev/prod parity
Keep environments as similar as possible
XI. Logs
Treat logs as event streams
XII. Admin processes
Run admin/management tasks as one-off processes
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
You know what’s great for a 12 factor app?
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
RUNNING A SINGLE CONTAINER
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
EC2 Instance
TaskTask
Task Task
EC2 Instance
TaskTask
Task Task
EC2 Instance
TaskTask
Task Task
EC2 Instance
TaskTask
Task Task
EC2 Instance
TaskTask
Task Task
RUNNING CONTAINERS
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
RUNNING CONTAINERS AT SCALE WITH ECS
Availability Zone #1 Availability Zone #2 Availability Zone #3
Scheduling and Orchestration
Cluster Manager Placement Engine
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ECS
AMI
Docker
agent
ECS
agent
ECSTaskECSTask
ECSTaskECSTask
EC2 Instance
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ECS
AMI
Docker
agent
ECS
agent
EC2 Instance
ECS
AMI
Docker
agent
ECS
agent
EC2 Instance
ECS
AMI
Docker
agent
ECS
agent
EC2 Instance
Scheduling and Orchestration
Cluster Manager Placement Engine
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“Just launch 10 copies of
my container distributed
across three availability
zones and connect them
to this load balancer”
X 10
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
One codebase tracked in revision control, many deploys
Deployed VersionCode Version Control
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Staging / QA
Production
Dev #1
Dev #2
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Explicitly declare and isolate dependencies
Dependencies
Binaries
Code
Application
Bundle
Dependency Declaration: Node.js
package.json
npm install
# - or -
yarn install
Dependency Declaration: Python
requirements.txt
pip install
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Dependencies
Dependencies
Binaries
Code
Dependency Declaration & Isolation: Docker
Dockerfile
docker build
Development
Production
docker run
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Store config in the environment
Development
Configuration
Production
Configuration
Development
Production
Development
Production
Same container deployed to both environments.
Configuration is part of the environment on the host.
At runtime the container gets config from the
environment.
Application code pulls from the environment
Environment is customized when docker runs a container
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Treat backing services as attached resources
PostgreSQLapp1
Host
app2 3rd party service
Treat local services just like remote third party ones
PostgreSQLapp1
app2
Load balancer
Use CNAMES for maximum flexibility
and easy reconfiguration
postgres.mycompany.com
app2.mycompany.com
Easily create and maintain custom maps of your applications
Before
Version 2
After
Version 2
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Strictly separate build and run stages
Build
Dependencies
Binaries
Code
Release
Config ReleaseBuild Artifact
+ =
Tagged image stored in ECR
Amazon Elastic Container Service
Config
Run
Task Definition Release v1
Task Definition Release v2
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Execute the app as one or more stateless processes
Stateful container stores state in local disk or local memory.
Workload ends up tied to a specific host that has state data.
eu-west-1b
Container 1
Disk
eu-west-1ceu-west-1a
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Stateful data
Use services:
• Amazon RDS
• Amazon DynamoDB
• Amazon ElasticCache
• Amazon ElasticSearch
• Amazon S3
• ……
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Export services via port binding
Port 32456
Port 32457
Port 32458
Port 32768
Port 33487
Port 32192
Port 32794
Port 32781
Match: /api/users*
Match: /api/auth*
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Scale out via the process model
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
RUNNING CONTAINERS AT SCALE WITH ECS
Availability Zone #1 Availability Zone #2 Availability Zone #3
Scheduling and Orchestration
Cluster Manager Placement Engine
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Scaling
Instance
Container 1
Instance Instance Instance Instance Instance
+
Container 1
Container 1
Container 1
Container 1
Container 1
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Maximize robustness with fast startup and graceful shutdown
Responsive Graceful ShutdownFast Launch
Fast Launch
Minimize the startup time of processes:
• Scale up faster in response to spikes
• Ability to move processes to another host as needed
• Replace crashed processes faster
Responsive, Graceful Shutdown
Should respond to SIGTERM by shutting down gracefully
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Keep development, staging, and production as similar as possible
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Dev #1
Dev #2
Staging / QA
Production
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Staging / QA
Production
Dev #1
Dev #2
Local Application Remote
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Treat logs as event streams
Docker connects container’s stdout to a log driver
Containerized code writes to stdout
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CLOUDWATCH LOGS CONFIGURATION
Use the awslogs driver to send
stdout from your application to
Cloudwatch logs
Create a log group in Cloudwatch
Configure the log driver in your
task definition
Remember to add permissions via
the Task Execution Role
{
"family": "scorekeep",
...
"containerDefinitions": [
{
"name":“scorekeep-frontend",
...
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "scorekeep",
"awslogs-region": “us-east-1",
"awslogs-stream-prefix": "scorekeep/frontend“}}
},
{
"name":“scorekeep-api",
...
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "scorekeep",
"awslogs-region": “us-east-1",
"awslogs-stream-prefix": "scorekeep/api"}}
}
]}
Task Definition
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CLOUDWATCH LOGS
Logs Tab in the
Task Detail Page
View logs in the ECS or Cloudwatch Console
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Run admin/management tasks as one-off processes
Admin / management processes are inevitable:
• Migrate database
• Repair some broken data
• Once a week move database records
older than X to cold storage
• Every day email a report to this person
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Building Blocks for Containerized 12 Factor apps
Compute
Developer Tools Logging & Monitoring
Storage & Database
Networking & API Proxy
AWS Elastic
Beanstalk
AWS
Fargate
Amazon
ECS
Amazon
DynamoDB
Amazon S3
Amazon
ElastiCache
Amazon RDSAmazon
ECR
Amazon
EKS
AWS X-RayAWS
CodeBuild
AWS
CodePipeline
AWS
Cloud9
Amazon
CloudWatch
AWS
CloudTrail
Amazon
SQS
Amazon
SNS
Amazon
MQ
Amazon API
Gateway
Elastic Load
Balancing
Amazon
Route 53
AWS Step
Functions
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Sébastien Stormacq
Technical Evangelist, AWS
@sebsto
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

AWS ECS vs EKS
AWS ECS vs EKSAWS ECS vs EKS
AWS ECS vs EKS
 
CI/CD on AWS
CI/CD on AWSCI/CD on AWS
CI/CD on AWS
 
Kubernetes Networking in Amazon EKS (CON412) - AWS re:Invent 2018
Kubernetes Networking in Amazon EKS (CON412) - AWS re:Invent 2018Kubernetes Networking in Amazon EKS (CON412) - AWS re:Invent 2018
Kubernetes Networking in Amazon EKS (CON412) - AWS re:Invent 2018
 
CI/CD with AWS Developer Tools and Fargate
CI/CD with AWS Developer Tools and FargateCI/CD with AWS Developer Tools and Fargate
CI/CD with AWS Developer Tools and Fargate
 
Amazon EKS Deep Dive
Amazon EKS Deep DiveAmazon EKS Deep Dive
Amazon EKS Deep Dive
 
Amazon EKS - Elastic Container Service for Kubernetes
Amazon EKS - Elastic Container Service for KubernetesAmazon EKS - Elastic Container Service for Kubernetes
Amazon EKS - Elastic Container Service for Kubernetes
 
Microservices for Startups - Donnie Prakoso - AWS - CC18
Microservices for Startups - Donnie Prakoso - AWS - CC18Microservices for Startups - Donnie Prakoso - AWS - CC18
Microservices for Startups - Donnie Prakoso - AWS - CC18
 
Getting Started with Amazon ECS: Run Docker Containers on AWS
Getting Started with Amazon ECS: Run Docker Containers on AWSGetting Started with Amazon ECS: Run Docker Containers on AWS
Getting Started with Amazon ECS: Run Docker Containers on AWS
 
Introduction to Amazon EKS
Introduction to Amazon EKSIntroduction to Amazon EKS
Introduction to Amazon EKS
 
Running a High-Performance Kubernetes Cluster with Amazon EKS (CON318-R1) - A...
Running a High-Performance Kubernetes Cluster with Amazon EKS (CON318-R1) - A...Running a High-Performance Kubernetes Cluster with Amazon EKS (CON318-R1) - A...
Running a High-Performance Kubernetes Cluster with Amazon EKS (CON318-R1) - A...
 
AWS Container services
AWS Container servicesAWS Container services
AWS Container services
 
Running kubernetes with amazon eks
Running kubernetes with amazon eksRunning kubernetes with amazon eks
Running kubernetes with amazon eks
 
Automatically scaling your Kubernetes workloads - SVC210-S - Santa Clara AWS ...
Automatically scaling your Kubernetes workloads - SVC210-S - Santa Clara AWS ...Automatically scaling your Kubernetes workloads - SVC210-S - Santa Clara AWS ...
Automatically scaling your Kubernetes workloads - SVC210-S - Santa Clara AWS ...
 
PaaS – From Code to Running Application using AWS Elastic Beanstalk (DEV323) ...
PaaS – From Code to Running Application using AWS Elastic Beanstalk (DEV323) ...PaaS – From Code to Running Application using AWS Elastic Beanstalk (DEV323) ...
PaaS – From Code to Running Application using AWS Elastic Beanstalk (DEV323) ...
 
Deep dive ECS & Fargate Deep Dive
Deep dive ECS & Fargate Deep DiveDeep dive ECS & Fargate Deep Dive
Deep dive ECS & Fargate Deep Dive
 
Running Kubernetes on AWS.pdf
Running Kubernetes on AWS.pdfRunning Kubernetes on AWS.pdf
Running Kubernetes on AWS.pdf
 
Automatically Scaling Your Kubernetes Workloads - SVC209-S - Anaheim AWS Summit
Automatically Scaling Your Kubernetes Workloads - SVC209-S - Anaheim AWS SummitAutomatically Scaling Your Kubernetes Workloads - SVC209-S - Anaheim AWS Summit
Automatically Scaling Your Kubernetes Workloads - SVC209-S - Anaheim AWS Summit
 
AWS Containers Day.pdf
AWS Containers Day.pdfAWS Containers Day.pdf
AWS Containers Day.pdf
 
Running Kubernetes with Amazon EKS - AWS Online Tech Talks
Running Kubernetes with Amazon EKS - AWS Online Tech TalksRunning Kubernetes with Amazon EKS - AWS Online Tech Talks
Running Kubernetes with Amazon EKS - AWS Online Tech Talks
 
Max Körbächer - AWS EKS and beyond – master your Kubernetes deployment on AWS...
Max Körbächer - AWS EKS and beyond – master your Kubernetes deployment on AWS...Max Körbächer - AWS EKS and beyond – master your Kubernetes deployment on AWS...
Max Körbächer - AWS EKS and beyond – master your Kubernetes deployment on AWS...
 

Similar a Breaking the Monolith road to containers.pdf

Similar a Breaking the Monolith road to containers.pdf (20)

Breaking the Monolith road to containers.pdf
Breaking the Monolith road to containers.pdfBreaking the Monolith road to containers.pdf
Breaking the Monolith road to containers.pdf
 
Breaking the Monolith Using AWS Container Services
Breaking the Monolith Using AWS Container ServicesBreaking the Monolith Using AWS Container Services
Breaking the Monolith Using AWS Container Services
 
Orchestrating containers on AWS | AWS Summit Tel Aviv 2019
Orchestrating containers on AWS  | AWS Summit Tel Aviv 2019Orchestrating containers on AWS  | AWS Summit Tel Aviv 2019
Orchestrating containers on AWS | AWS Summit Tel Aviv 2019
 
Orchestrating containers on AWS | AWS Summit Tel Aviv 2019
Orchestrating containers on AWS  | AWS Summit Tel Aviv 2019Orchestrating containers on AWS  | AWS Summit Tel Aviv 2019
Orchestrating containers on AWS | AWS Summit Tel Aviv 2019
 
Modern-Application-Design-with-Amazon-ECS
Modern-Application-Design-with-Amazon-ECSModern-Application-Design-with-Amazon-ECS
Modern-Application-Design-with-Amazon-ECS
 
Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...
Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...
Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...
 
AWS Accra Meetup - Developing Modern Applications in the Cloud
AWS Accra Meetup - Developing Modern Applications in the CloudAWS Accra Meetup - Developing Modern Applications in the Cloud
AWS Accra Meetup - Developing Modern Applications in the Cloud
 
[CPT DevOps Meetup] Developing Modern Applications in the Cloud
[CPT DevOps Meetup] Developing Modern Applications in the Cloud[CPT DevOps Meetup] Developing Modern Applications in the Cloud
[CPT DevOps Meetup] Developing Modern Applications in the Cloud
 
AWS Jozi Meetup Developing Modern Applications in the Cloud
AWS Jozi Meetup Developing Modern Applications in the CloudAWS Jozi Meetup Developing Modern Applications in the Cloud
AWS Jozi Meetup Developing Modern Applications in the Cloud
 
AWS Container Services – 유재석 (AWS 솔루션즈 아키텍트)
AWS Container Services – 유재석 (AWS 솔루션즈 아키텍트)AWS Container Services – 유재석 (AWS 솔루션즈 아키텍트)
AWS Container Services – 유재석 (AWS 솔루션즈 아키텍트)
 
Amazon Container Services – 유재석 (AWS 솔루션즈 아키텍트)
 Amazon Container Services – 유재석 (AWS 솔루션즈 아키텍트) Amazon Container Services – 유재석 (AWS 솔루션즈 아키텍트)
Amazon Container Services – 유재석 (AWS 솔루션즈 아키텍트)
 
Building Secure Services using Containers
Building Secure Services using ContainersBuilding Secure Services using Containers
Building Secure Services using Containers
 
Architecting security and governance through policy guardrails in Amazon EKS ...
Architecting security and governance through policy guardrails in Amazon EKS ...Architecting security and governance through policy guardrails in Amazon EKS ...
Architecting security and governance through policy guardrails in Amazon EKS ...
 
Container, Container, Container -유재석 (AWS 솔루션즈 아키텍트)
Container, Container, Container -유재석 (AWS 솔루션즈 아키텍트)Container, Container, Container -유재석 (AWS 솔루션즈 아키텍트)
Container, Container, Container -유재석 (AWS 솔루션즈 아키텍트)
 
Earn Your DevOps Black Belt: Deployment Scenarios with AWS CloudFormation (DE...
Earn Your DevOps Black Belt: Deployment Scenarios with AWS CloudFormation (DE...Earn Your DevOps Black Belt: Deployment Scenarios with AWS CloudFormation (DE...
Earn Your DevOps Black Belt: Deployment Scenarios with AWS CloudFormation (DE...
 
Serverless and Containers, AWS Federal Pop-Up Loft
Serverless and Containers, AWS Federal Pop-Up LoftServerless and Containers, AWS Federal Pop-Up Loft
Serverless and Containers, AWS Federal Pop-Up Loft
 
AWS 고객사를 위한 ‘AWS 컨테이너 교육’ - 유재석, AWS 솔루션즈 아키텍트
AWS 고객사를 위한 ‘AWS 컨테이너 교육’ - 유재석, AWS 솔루션즈 아키텍트AWS 고객사를 위한 ‘AWS 컨테이너 교육’ - 유재석, AWS 솔루션즈 아키텍트
AWS 고객사를 위한 ‘AWS 컨테이너 교육’ - 유재석, AWS 솔루션즈 아키텍트
 
Getting Started with ARM-Based EC2 A1 Instances - CMP302 - Anaheim AWS Summit
Getting Started with ARM-Based EC2 A1 Instances - CMP302 - Anaheim AWS SummitGetting Started with ARM-Based EC2 A1 Instances - CMP302 - Anaheim AWS Summit
Getting Started with ARM-Based EC2 A1 Instances - CMP302 - Anaheim AWS Summit
 
Breaking the Monolith using AWS Container Services
Breaking the Monolith using AWS Container ServicesBreaking the Monolith using AWS Container Services
Breaking the Monolith using AWS Container Services
 
Driving Innovation with Serverless Applications (GPSBUS212) - AWS re:Invent 2018
Driving Innovation with Serverless Applications (GPSBUS212) - AWS re:Invent 2018Driving Innovation with Serverless Applications (GPSBUS212) - AWS re:Invent 2018
Driving Innovation with Serverless Applications (GPSBUS212) - AWS re:Invent 2018
 

Más de Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 

Más de Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Breaking the Monolith road to containers.pdf

  • 1. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. 28.03.2019 S T O C K H O L M
  • 2. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S T O C K H O L M 28.03.2019 Breaking the Monolith Modern Application Design with Containers and the 12 factors app Sébastien Stormacq Technical Evangelist, AWS @sebsto M A D 4
  • 3. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Best Software Architecture Practices Use declarative formats for setup automation, to minimize time and cost for new developers joining the project; Have a clean contract with the underlying operating system, offering maximum portability between execution environments; Are suitable for deployment on modern cloud platforms, obviating the need for servers and systems administration; Minimize divergence between development and production, enabling continuous deployment for maximum agility; And can scale up without significant changes to tooling, architecture, or development practices.
  • 4. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 5. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. The 12 factor application I. Codebase One codebase w/ revision control, many deploys II. Dependencies Explicitly declare and isolate dependencies III. Config Store config in the environment IV. Backing services Treat backing services as attached resources V. Build, release, run Strictly separate build and run stages VI. Processes Execute the app as one or more stateless processes VII. Port binding Export services via port binding VIII. Concurrency Scale out via the process model IX. Disposability Fast startup and graceful shutdown X. Dev/prod parity Keep environments as similar as possible XI. Logs Treat logs as event streams XII. Admin processes Run admin/management tasks as one-off processes
  • 6. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. You know what’s great for a 12 factor app?
  • 7. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 8. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. RUNNING A SINGLE CONTAINER
  • 9. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. EC2 Instance TaskTask Task Task EC2 Instance TaskTask Task Task EC2 Instance TaskTask Task Task EC2 Instance TaskTask Task Task EC2 Instance TaskTask Task Task RUNNING CONTAINERS
  • 10. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. RUNNING CONTAINERS AT SCALE WITH ECS Availability Zone #1 Availability Zone #2 Availability Zone #3 Scheduling and Orchestration Cluster Manager Placement Engine
  • 11. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. ECS AMI Docker agent ECS agent ECSTaskECSTask ECSTaskECSTask EC2 Instance
  • 12. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. ECS AMI Docker agent ECS agent EC2 Instance ECS AMI Docker agent ECS agent EC2 Instance ECS AMI Docker agent ECS agent EC2 Instance Scheduling and Orchestration Cluster Manager Placement Engine
  • 13. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. “Just launch 10 copies of my container distributed across three availability zones and connect them to this load balancer” X 10
  • 14. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. One codebase tracked in revision control, many deploys
  • 16. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Staging / QA Production Dev #1 Dev #2
  • 17. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Explicitly declare and isolate dependencies
  • 19. Dependency Declaration: Node.js package.json npm install # - or - yarn install
  • 21. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Dependencies Dependencies Binaries Code
  • 22. Dependency Declaration & Isolation: Docker Dockerfile docker build
  • 24. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Store config in the environment
  • 26. Development Production Same container deployed to both environments. Configuration is part of the environment on the host.
  • 27. At runtime the container gets config from the environment.
  • 28. Application code pulls from the environment Environment is customized when docker runs a container
  • 29. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Treat backing services as attached resources
  • 30. PostgreSQLapp1 Host app2 3rd party service Treat local services just like remote third party ones
  • 31. PostgreSQLapp1 app2 Load balancer Use CNAMES for maximum flexibility and easy reconfiguration postgres.mycompany.com app2.mycompany.com
  • 32. Easily create and maintain custom maps of your applications Before Version 2 After Version 2
  • 33. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Strictly separate build and run stages
  • 35. Release Config ReleaseBuild Artifact + = Tagged image stored in ECR
  • 36. Amazon Elastic Container Service Config
  • 37. Run Task Definition Release v1 Task Definition Release v2
  • 38. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Execute the app as one or more stateless processes
  • 39. Stateful container stores state in local disk or local memory. Workload ends up tied to a specific host that has state data. eu-west-1b Container 1 Disk eu-west-1ceu-west-1a
  • 40. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Stateful data Use services: • Amazon RDS • Amazon DynamoDB • Amazon ElasticCache • Amazon ElasticSearch • Amazon S3 • ……
  • 41. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Export services via port binding
  • 43. Port 32768 Port 33487 Port 32192 Port 32794 Port 32781 Match: /api/users* Match: /api/auth*
  • 44. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Scale out via the process model
  • 45. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. RUNNING CONTAINERS AT SCALE WITH ECS Availability Zone #1 Availability Zone #2 Availability Zone #3 Scheduling and Orchestration Cluster Manager Placement Engine
  • 46. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Scaling Instance Container 1 Instance Instance Instance Instance Instance + Container 1 Container 1 Container 1 Container 1 Container 1
  • 47. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Maximize robustness with fast startup and graceful shutdown
  • 49. Fast Launch Minimize the startup time of processes: • Scale up faster in response to spikes • Ability to move processes to another host as needed • Replace crashed processes faster
  • 50. Responsive, Graceful Shutdown Should respond to SIGTERM by shutting down gracefully
  • 51. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Keep development, staging, and production as similar as possible
  • 52. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Dev #1 Dev #2 Staging / QA Production
  • 53. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Staging / QA Production Dev #1 Dev #2 Local Application Remote
  • 54. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Treat logs as event streams
  • 55. Docker connects container’s stdout to a log driver Containerized code writes to stdout
  • 56. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CLOUDWATCH LOGS CONFIGURATION Use the awslogs driver to send stdout from your application to Cloudwatch logs Create a log group in Cloudwatch Configure the log driver in your task definition Remember to add permissions via the Task Execution Role { "family": "scorekeep", ... "containerDefinitions": [ { "name":“scorekeep-frontend", ... "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "scorekeep", "awslogs-region": “us-east-1", "awslogs-stream-prefix": "scorekeep/frontend“}} }, { "name":“scorekeep-api", ... "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "scorekeep", "awslogs-region": “us-east-1", "awslogs-stream-prefix": "scorekeep/api"}} } ]} Task Definition
  • 57. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. CLOUDWATCH LOGS Logs Tab in the Task Detail Page View logs in the ECS or Cloudwatch Console
  • 58. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Run admin/management tasks as one-off processes
  • 59. Admin / management processes are inevitable: • Migrate database • Repair some broken data • Once a week move database records older than X to cold storage • Every day email a report to this person
  • 60. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 61. Building Blocks for Containerized 12 Factor apps Compute Developer Tools Logging & Monitoring Storage & Database Networking & API Proxy AWS Elastic Beanstalk AWS Fargate Amazon ECS Amazon DynamoDB Amazon S3 Amazon ElastiCache Amazon RDSAmazon ECR Amazon EKS AWS X-RayAWS CodeBuild AWS CodePipeline AWS Cloud9 Amazon CloudWatch AWS CloudTrail Amazon SQS Amazon SNS Amazon MQ Amazon API Gateway Elastic Load Balancing Amazon Route 53 AWS Step Functions
  • 62. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 63. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Sébastien Stormacq Technical Evangelist, AWS @sebsto
  • 64. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.