Overview
This page is the atomic definition. The broader principles live at general-principles.
Definition
The twelve-factor app is a methodology of twelve rules for building portable, deployable web services, published by the Heroku team in 2011. The rules are: 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 processes. The central themes are declared dependencies, externalized config (in environment variables), stateless processes, and treating attached services as resources. Modern PaaS providers like Vercel, Fly.io, and Railway assume twelve-factor compliance.
When it applies
Apply twelve-factor rules to any web service that runs on a PaaS, in containers, or behind a load balancer. Most rules still apply to serverless functions; processes are even more disposable there.
Example
A FastAPI service reads its database URL from DATABASE_URL (factor 3: config), logs to stdout instead of files (factor 11: logs), and exits cleanly on SIGTERM within 10 seconds (factor 9: disposability). The same image runs locally, in staging, and in production with no code changes.
Related concepts
- general-principles - the broader principles that include twelve-factor.
- config-files - the externalized-config rule in practice.
- observability - the logs-as-event-streams rule in practice.
- vercel - a PaaS that assumes twelve-factor compliance.
- migrations - admin processes as one-off runs against production.
Citing this term
See Twelve-factor app (llmbestpractices.com/glossary/twelve-factor).