Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Breaking the Monolith road to containers.pdf

151 visualizaciones

Publicado el

Following simple patterns of good application design can allow you to scale your application for your customers easily. We'll dive into the 12 factor application design and demo how this applies to containers and deployments on Amazon ECS and Fargate. We'll take a look at tooling that can be used to simplfy your work flow and help you adopt the principles of the 12 factor application.

  • Sé el primero en comentar

Breaking the Monolith road to containers.pdf

  1. 1. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. 04.03.2019 O S L O
  2. 2. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. O S L O 04.03.2019 Breaking the Monolith Modern Application Design with Containers and the 12 factors app Sébastien Stormacq Technical Evangelist, AWS @sebsto #AWSDevDay M A D 4
  3. 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. 4. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  5. 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. 6. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. You know what’s great for a 12 factor app?
  7. 7. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  8. 8. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. RUNNING A SINGLE CONTAINER
  9. 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. 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. 11. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. ECS AMI Docker agent ECS agent ECSTaskECSTask ECSTaskECSTask EC2 Instance
  12. 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. 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. 14. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. One codebase tracked in revision control, many deploys
  15. 15. Deployed VersionCode Version Control
  16. 16. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Staging / QA Production Dev #1 Dev #2
  17. 17. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Explicitly declare and isolate dependencies
  18. 18. Dependencies Binaries Code Application Bundle
  19. 19. Dependency Declaration: Node.js package.json npm install # - or - yarn install
  20. 20. Dependency Declaration: Python requirements.txt pip install
  21. 21. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Dependencies Dependencies Binaries Code
  22. 22. Dependency Declaration & Isolation: Docker Dockerfile docker build
  23. 23. Development Production docker run
  24. 24. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Store config in the environment
  25. 25. Development Configuration Production Configuration Development Production
  26. 26. Development Production Same container deployed to both environments. Configuration is part of the environment on the host.
  27. 27. At runtime the container gets config from the environment.
  28. 28. Application code pulls from the environment Environment is customized when docker runs a container
  29. 29. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Treat backing services as attached resources
  30. 30. PostgreSQLapp1 Host app2 3rd party service Treat local services just like remote third party ones
  31. 31. PostgreSQLapp1 app2 Load balancer Use CNAMES for maximum flexibility and easy reconfiguration postgres.mycompany.com app2.mycompany.com
  32. 32. Easily create and maintain custom maps of your applications Before Version 2 After Version 2
  33. 33. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Strictly separate build and run stages
  34. 34. Build Dependencies Binaries Code
  35. 35. Release Config ReleaseBuild Artifact + = Tagged image stored in ECR
  36. 36. Amazon Elastic Container Service Config
  37. 37. Run Task Definition Release v1 Task Definition Release v2
  38. 38. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Execute the app as one or more stateless processes
  39. 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. 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. 41. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Export services via port binding
  42. 42. Port 32456 Port 32457 Port 32458
  43. 43. Port 32768 Port 33487 Port 32192 Port 32794 Port 32781 Match: /api/users* Match: /api/auth*
  44. 44. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Scale out via the process model
  45. 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. 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. 47. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Maximize robustness with fast startup and graceful shutdown
  48. 48. Responsive Graceful ShutdownFast Launch
  49. 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. 50. Responsive, Graceful Shutdown Should respond to SIGTERM by shutting down gracefully
  51. 51. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Keep development, staging, and production as similar as possible
  52. 52. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Dev #1 Dev #2 Staging / QA Production
  53. 53. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Staging / QA Production Dev #1 Dev #2 Local Application Remote
  54. 54. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Treat logs as event streams
  55. 55. Docker connects container’s stdout to a log driver Containerized code writes to stdout
  56. 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. 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. 58. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Run admin/management tasks as one-off processes
  59. 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. 60. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  61. 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. 62. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  63. 63. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Sébastien Stormacq Technical Evangelist, AWS @sebsto
  64. 64. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.

×