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

12 Factors of Pain and Suffering

12 Factors of Pain and Suffering

Want to build simple, scalable and reliable web applications? In this presentation, you'll learn all about the 12-Factor App, and the principles it teaches.

You'll also see firsthand how even an experienced programmer has screwed up these best practices in every way imaginable, sometimes with terrible consequences.

Randall Degges

November 14, 2019

More Decks by Randall Degges

Other Decks in Programming


  1. @rdegges The 12 Factor App "A methodology for building simple,

    scalable, and dependable web applications."
  2. @rdegges 818-217-9229 - Randall Degges - Granada Hills, CA 94519

    - He is *not* a spam bot - Etc... $$$ I hate your website. CODEBASE newsketchdomain.com CODEBASE1 CODEBASE2 domain1.com domain2.com CTRL-C + CTRL-V
  3. @rdegges How It Works { "dependencies": { "axios": "^0.18.0", "dotenv":

    "^6.1.0", "express": "^4.16.4", "vue": "^2.5.17" } } Declare Dependencies $ npm install + [email protected] + [email protected] + [email protected] + [email protected] added 57 packages from 41 contributors and audited 128 packages in 2.064s found 0 vulnerabilities Isolate Dependencies
  4. @rdegges Image Optimization API Shrink this image! OK! Let me

    optimize that for you. VPS - optipng - jpegoptim - gifsicle - ... code optipng gifsicle
  5. @rdegges IV. Backing Services Treat backing services as attached resources.

    Production Deploy Postgres S3 SMTP smtp://auth@host https://[email protected] postgres://auth@host/db
  6. @rdegges Blog MySQL I should make a blog. I should

    give out pirated movies to everyone. ERROR: No disk space MySQL
  7. @rdegges VII. Port Binding Expose services via port binding.

    localhost:443 Routing App $PORT App $PORT App $PORT
  8. @rdegges VIII. Concurrency Scale out via the process model. web.1

    web.2 worker.1 worker.2 worker.3 worker.4 clock.1 Process Types Scale
  9. @rdegges IX. Disposability Maximize robustness with fast startup and graceful

    shutdown. Shut down gracefully when SIGTTERM is received Shut down within a few seconds Be robust against sudden death
  10. @rdegges Process 1 Load Balancer Requests Process 2 Process 3

    Process 4 Process 5 def startup(): download_audio() listen(env["PORT"])
  11. @rdegges X. Dev/Prod Parity Keep development, staging, and production as

    similar as possible. Code Postgres SQLite VARCHARRRRR
  12. @rdegges XI. Logs Treat logs as event streams. App <log

    entry> <log entry> <log entry> <log entry> <log entry> <log entry> <log entry> ... Order by timestamp Write to STDOUT Consist of *all* process and backing services logs
  13. @rdegges Conference Call Web App Conference Call API Asterisk Asterisk

    Asterisk <billable call> <billable call> <billable call> <billable call> <billable call> ... calls.csv $ scp root@...:calls.csv . Log Router
  14. @rdegges XII. Admin Processes Run admin/management tasks as one-off processes.

    Code Admin Task Run a database migration $ python manage.py migrate Prod Infrastructure
  15. @rdegges Run a database migration New Feature Alter Table DB

    Migration Code "I only need to do this once… So..." $ python manage.py migrate Deploy Feature!