The 12-Factor App
The 12-Factor App principles for deployable, configurable, and scalable services.
The 12-Factor App is a set of design principles for building applications that are easy to deploy, scale, and operate. It came from the world of cloud platforms, but the ideas still matter because they separate code from environment, encourage automation, and reduce hidden coupling between deployment and runtime behaviour.
The twelve factors in plain terms
1. Codebase means one tracked codebase per app, with many deploys if needed. This sounds obvious, but it prevents the chaos of manually synchronised variants.
2. Dependencies means declare and isolate everything the app needs. Hidden system packages and ad hoc install steps make environments drift.
3. Config means environment-specific settings live outside the codebase. Credentials, endpoints, and feature toggles should change without rebuilding the application.
4. Backing services means databases, queues, and caches are treated as attached resources. The app should bind to them through configuration rather than assumptions about one special environment.
5. Build, release, run means separate packaging from deployment and runtime. This improves reproducibility and makes rollbacks more disciplined.
6. Processes means run the app as stateless processes where possible. Persistent state belongs in backing services, not inside one instance’s memory or local disk.
7. Port binding means the app exports services by binding to a port rather than relying on an external web server to inject the runtime contract.
8. Concurrency means scale by adding more process instances for suitable workloads. This encourages horizontal thinking instead of one giant server.
9. Disposability means fast start-up and graceful shutdown. Processes should be easy to replace, which improves deploys, autoscaling, and crash recovery.
10. Dev/prod parity means keep development, staging, and production reasonably close. Big environmental gaps are a reliable source of deployment surprises.
11. Logs means treat logs as event streams rather than files managed manually inside the app.
12. Admin processes means one-off tasks such as migrations or backfills should run in the same codebase and environment model as the main app, but as separate processes.
Why the model still helps
The value of the 12-factor approach is not that every application must follow each rule literally. The value is that it exposes common operational traps: configuration baked into code, mutable servers, local-only state, and release processes that depend on human memory.
Where it needs interpretation
Modern systems sometimes extend the model. Containers, serverless runtimes, and data-heavy applications introduce nuances the original text did not emphasise. For example, some workloads are intentionally stateful. Some background systems need durable local caches. The principle still holds if you treat those exceptions explicitly instead of accidentally.
The best use of 12-factor thinking is as a bias toward portability, automation, and operational clarity.