Overview
The twelve factors are Codebase, Dependencies, Config, Backing services, Build/release/run, Processes, Port binding, Concurrency, Disposability, Dev/prod parity, Logs, and Admin processes. Use them as a checklist when a service must run the same way on a laptop, in CI, and in production. Externalized config and stateless processes pay off first.
Rules
- Dependencies (2) and backing services (4): declare every dependency in a manifest, and address databases and queues as attached resources through config URLs so swapping one needs no code change.
- Config (3): read it from the environment, such as
DATABASE_URL, never from per-environment files in the repo. - Processes (6): keep them stateless; store state in backing services.
- Disposability (9): start fast and exit cleanly on
SIGTERM. - Logs (11): write to stdout as an event stream and let the platform collect it.
- Admin processes (12): run migrations and one-off scripts as one-off processes against the same release.
- Most factors still apply to containers and serverless functions.
Related
- general-principles: the wider design principles.
- config-files: externalized config in practice.
- secrets-and-env: handling environment secrets.
- observability: logs as event streams.
- migrations: admin processes against production.