Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Building Microservices with the 12 Factor App Pattern on AWS - AWS Online Tech Talks

1,850 views

Published on

Learning Objectives:
- Learn best practices for building containerized microservices
- Learn about the twelve-factor app pattern and how to implement it using containers on AWS
- Learn how to use AWS Fargate to build and run containerized microservices

Building Microservices with the 12 Factor App Pattern on AWS - AWS Online Tech Talks

  1. 1. AWS Webinars Building Microservices with the 12 Factor App Pattern on AWS Abby Fuller Developer Relations, AWS
  2. 2. 12 Factor App Principles Microservice Principles Great, Scalable Architecture + =
  3. 3. 12 Factor Application: Codebase
  4. 4. Code
  5. 5. Code Version Control
  6. 6. Code Deployed VersionVersion Control
  7. 7. Staging / QA Production Dev #1 Dev #2
  8. 8. 12 Factor Application: Dependencies
  9. 9. Dependencies Binaries Code Application Bundle
  10. 10. Dependency Declaration: Node.js package.json npm install
  11. 11. Dependency Declaration: Python requirements.txt pip install
  12. 12. Dependency Declaration: Ruby Gemfile bundle install
  13. 13. Dependency Isolation Never depend on the host to have your dependency. Application deployments should carry all their dependencies with them.
  14. 14. Dependencies Binaries Code
  15. 15. Dependency Declaration & Isolation: Docker docker build Dockerfile
  16. 16. Development Production docker run
  17. 17. 12 Factor Application: Config
  18. 18. Development Configuration Production Configuration Development Production
  19. 19. Development Configuration Production Configuration Development Production ANTIPATTERN
  20. 20. Development Production Same container deployed to both environments. Configuration is part of the environment on the host.
  21. 21. At runtime the container gets config from the environment.
  22. 22. Application code pulls from the environment Environment is customized when docker runs a container
  23. 23. 12 Factor Application: Backing Services
  24. 24. AWS S3 PostgreSQLapp1 Host app2 3rd party service Treat local services just like remote third party ones
  25. 25. PostgreSQLapp1 app2 postgres.mycompany.com app2.mycompany.com Load balancer Use CNAMES for maximum flexibility and reconfigurability
  26. 26. 12 Factor Application: Build, Release, Run
  27. 27. Dependencies Binaries Code Build
  28. 28. Release Config + = Release Build Artifact
  29. 29. Amazon Elastic Container Service Config
  30. 30. Task Definition Release v1.0.0 Run Task Definition Release v1.0.1
  31. 31. 12 Factor Application: Stateless Processes
  32. 32. Stateful container stores state in local disk or local memory. Workload ends up tied to a specific host that has state data.
  33. 33. Stateful container stores state in local disk or local memory. Workload ends up tied to a specific host that has state data. ANTIPATTERN
  34. 34. Database Durable store of truth. MySQL, PostgreSQL, MongoDB, DynamoDB Cache Fast, temporary state store. redis, memcached
  35. 35. 12 Factor Application: Port Binding
  36. 36. Port 32456 Port 32457 Port 32458
  37. 37. 12 Factor Application: Concurrency
  38. 38. WebAPI Worker
  39. 39. Worker Web API
  40. 40. Hosts Processes
  41. 41. Hosts Processes
  42. 42. Large Host = More Concurrent Processes Small Host = Fewer Concurrent Processes
  43. 43. 12 Factor Application: Disposability
  44. 44. Responsive Graceful ShutdownFast Launch
  45. 45. 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
  46. 46. Responsive, Graceful Shutdown Should respond to SIGTERM by shutting down gracefully
  47. 47. 12 Factor Application: Dev/Prod Parity
  48. 48. Staging / QA Production Dev #1 Dev #2
  49. 49. Staging / QA Production Dev #1 Dev #2 Local Application Remote
  50. 50. 12 Factor Application: Logs
  51. 51. Treat logs as an event stream, and keep the logic for routing and processing logs separate from the application itself.
  52. 52. Logging Library Application Code Process
  53. 53. Logging Library Application Code Process Some logs get lost if they haven’t fully flushed
  54. 54. Logging Library Application Code Process Some logs get lost if they haven’t fully flushed ANTIPATTERN
  55. 55. Processes Logging Agent Application Code Logs go to an agent which handles exporting them off the host
  56. 56. Processes Logging Agent Application Code Logs still reach agent, and still make it into ELK stack
  57. 57. Containerized code writes to stdout Docker connects container’s stdout to a log driver
  58. 58. 12 Factor Application: Admin 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. Run admin processes just like other processes.
  61. 61. Microservices: Componentization
  62. 62. Each component is a 12 factor application. Fast Launch Dependencies Configuration Port BindingCodebase ConcurrentGraceful stop Log stream Stateless
  63. 63. Microservices: Organized around capabilities
  64. 64. Identify the capabilities of the platform
  65. 65. Each major capability of the platform becomes a component that is its own 12 factor app
  66. 66. Microservices: Decentralized Governance
  67. 67. Microservices: Products Not Projects
  68. 68. Products grow over time
  69. 69. Microservices are an ecosystem of connected products that can be at different stages of growth
  70. 70. Don’t create throwaway microservices that become unmaintained and break the ecosystem.
  71. 71. Microservices: Smart endpoints, Dumb pipes
  72. 72. Central bus for communication Bottlenecks performance and feature development
  73. 73. Central bus for communication Bottlenecks performance and feature development
  74. 74. Decentralization
  75. 75. Example: User Signup Signup API HTTP User Metadata Service Password Service Email Verification Service Friend Discovery Service Asynchronous Broadcast
  76. 76. Event Producers SubscriptionsEvent Topics Queues Event Consumers
  77. 77. Amazon Managed Service for Microservice Communication
  78. 78. Microservices: Infrastructure Automation
  79. 79. Automate the container build process: Jenkins AWS CodeBuild
  80. 80. Automate the provisioning of the servers that host microservice containers: Terraform, Ansible, Amazon CloudFormation Automate the placement of containerized service processes onto hosts: Amazon Elastic Container Service, Kubernetes, Docker Swarm
  81. 81. Developers Version Control Repository Test & Deployment Manager Image Build Service Infrastructure Provisioning Container Scheduling & Orchestration Container Image Repository
  82. 82. Developers AWS CodeCommit AWS CodePipeline AWS CodeBuild AWS CloudFormation Amazon ECS Amazon ECR
  83. 83. Developers Github Jenkins Terraform Container Scheduling & Orchestration with Kubernetes Container Image Repository
  84. 84. Summary
  85. 85. 12 factor application principles Fast Launch Dependencies Configuration Port BindingCodebase ConcurrentGraceful stop Log stream Stateless
  86. 86. Microservice principles Automation Componentization Product Focused Decentralization
  87. 87. Thank you! abbyfull@amazon.com abbyfuller abby-fuller

×