Upgrade to Pro — share decks privately, control downloads, hide ads and more …

12 Factor Applications

12 Factor Applications

Learn how to leverage the 12 Factor App methodology to deliver software that can be scaled, deployed and easily maintained.

Most importantly, learn to embed the methodology into your software development lifecycle to deliver better software.

Presented at forLoop Ibadan - Software Development LifeCycle event - March 17th, 2018

forLoop Ibadan is a child community of forLoop Africa. forLoop Africa is the fastest growing developer community in Africa.

Adegoke Obasa

March 17, 2018
Tweet

More Decks by Adegoke Obasa

Other Decks in Programming

Transcript

  1. About Me Lead Engr. DevOps / Mobile - Cotta &

    Cush Organiser - GDG Ibadan Founder / Editor - Continuous Bytes Ex Software Engr. - Releaf, Sanwo, Konga Tweets - @goke_
  2. 12 Factor App • A programming language, service and cloud

    provider agnostic (independent) methodology for managing application lifecycle • Based on Heroku’s experience of developing, operating, and scaling of 100,000s of apps
  3. Benefits of the 12 Factor App Approach • Minimizes divergence

    between environments • Easier deployment to the cloud - IAAS, PAAS and CAAS • Apps are easier to scale up without making significant changes to code and development processes • Easier onboarding of new members to the development team
  4. The 12 Factors 1. Codebase 2. Dependencies 3. Config 4.

    Backing Services 5. Build, Release, Run 6. Processes 7. Port Binding 8. Concurrency 9. Disposability 10. Dev/prod Parity 11. Logs 12. Admin Process NB: Focus would be on the factors in bold
  5. Codebase Track your app source code in a Version Control

    System (VCS). Examples of VCS • Git • Subversion (SVN) • Mercurial
  6. 1 - Codebase - Dos and Don’ts Dos • Use

    Single Codebase Don’ts • Use Multiple Codebases • Have Multiple Apps sharing Codebase
  7. Dependencies - Dos and Don’ts Dos • Use a Package

    Manager • Specify exact version • Version control lock file Don’ts • Rely on implicit existence of system-wide packages • Add library source to app codebase
  8. Config - Dos and Don’ts Dos • Store configuration as

    environment variables Don’ts • Hardcode configuration • Create different config file per environment
  9. Accessing Environment Variables Language Code PHP getenv(<VAR_NAME>) JavaScript: NodeJS process.env.<VAR_NAME>

    Java System.getenv(<VAR_NAME>) Suggestion: Use dotenv library NB: Don’t push .env file to the code repository
  10. Backing Services A backing service is any service the app

    consumes over the network as part of its normal operation. Some Services • Datastores • Queuing Systems • Caching Systems • File Storage Services
  11. Examples of Backing Services Service Examples Datastores MySQL, MongoDB, Postgres

    Queuing Systems ActiveMQ, RabbitMQ, Beanstalkd Caching Systems Redis, Memcached SMTP Services Sendgrid, Postmark
  12. Backing Services - Dos and Don’ts Dos • Access services

    via a URL or other locator/credentials stored in the config Don’ts • Make a distinction between local and 3rd party services
  13. Build, Release, Run Build Tools • Ant • Gradle •

    Gulp • Webpack Deployment Tools • Capistrano • Deployer • Fabric
  14. Build, Release, Run - Steps Build - Converts a code

    repository into a build, using the code at the commit or tag specified by the deployment process. Release - Combines build from build stage with the deploys current config. Run - Executes the app by starting a process against the app's current release.
  15. 10 - Dev / Prod Parity Keep development, staging, and

    production as similar as possible
  16. Environments Explained • Development (Dev) - a developer making live

    edits to a local deploy of the app • Production (Prod) - a running deploy of the app accessed by end users
  17. Challenges - Time Personnel Tools • Time - How long

    does it take to deploy • Personnel - Code is written by developers, DevOps engineers deploy it • Tools - Difference in stack of Dev and Prod
  18. Dev / Prod Parity Dos • Keep deploy time as

    short as possible • Understand deployment and be closely involved • Ensure difference in Dev and Prod stack is very minimal Don’ts • Use lightweight backing services on Dev and heavyweight services on Prod
  19. A Quick Walkthrough of an Existing App App - Cotta&Cush

    Yii2 Base Project • Codebase - Code • Dependencies - Code • Config - Code • Backing Services - Code • Build, Release, Run - Code
  20. References 12 Factor App Website - https://12factor.net/ Twelve-Factor Apps In

    node.js - https://peterlyons.com/twelve-factor-nodejs