Twelve Factors

This is my summary of twelve factors for building a web app, software as as service. (, which is published by Heroku co-founder Adam Wiggins.

  1. Codebase: use a version control, which maintains a single codebase per an web app. One codebase can have multiple deployments.

  2. Dependencies: use a package manager to declare dependency libraries explicitly and to isolate them.

  3. Config: store config in environment variables, in which way config can be in different env. groups (like development, staging, production).

  4. Backing services: treat backing services (datastore, messaging, emailing, cashing) as a attached service. They should be detached and attached without any code change.

  5. Build, release, run - separate build, release, and run stages. The run stage runs an app by launching the app's process. alt

  6. Processes - an app runs on one or more processes. Each process should be stateless, which means that nothing is shared among processes. Any persistent data must be stored in stateful database.

  7. Port Binding - an web app will be served with its own url, as backing services do. In this ways, the app can serve as an backing service for other services.

  8. Concurrency - Organizing the same type of workloads to certain process type, scaling be easier when the app grows.

  9. Disposability - the app's processes are disposable, which means that they should stop and start its service quickly without interrupting users.

  10. Dev/Prod parity - Keep development, staging, and production as similar as possible. The smaller the gap among them is, the easier the project management is.

  11. Logs - treat logs as event streams which can be visible in development terminal, or can be captured/written in a log disk so that they can be later analyzed.

  12. Admin Processes - One-off administrative or maintenance tasks on an production app should be handy. The One-off admin processes run in an identical environment as the regular long-running processes of the app.