Más contenido relacionado La actualidad más candente (20) Similar a Breaking the Monolith road to containers.pdf (20) Más de Amazon Web Services (20) Breaking the Monolith road to containers.pdf1. © 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
21. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Dependencies
Dependencies
Binaries
Code
24. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Store config in the environment
29. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Treat backing services as attached resources
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
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
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
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
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.