From Heroku, where the methodology originated in 2011, written by Adam Wiggins and published at 12factor.net.
Twelve rules for building software-as-a-service applications so that any copy of the app is portable, can be deployed often and without ceremony, and can scale by adding identical processes.
Five choices in an order-taking service, and what each one does to the next change
The service runs two servers for restaurant orders. Each row is a choice the twelve-factor method speaks to, and the four results under it say whether an extra server, a quick rollback, a safe daytime release, and a day-one copy are possible. Switch rows until all four results read yes. Illustrative.
Where settings live
Where a diner's session lives
How a release reaches production
Local versus production
When a server is stopped
- Some choices are fixed and others still block a result. Read which results below still say no.Friday's third server logs diners out at random, every change is an edit on a live machine, and nobody can try a release before the dinner rush.A server can be added or removed at any hour, a release is a numbered artifact that can be undone, and a new developer can run a copy on day one.
- Friday's third server logs diners out at random, every change is an edit on a live machine, and nobody can try a release before the dinner rush. (config: In the code, state: In one server's memory, rel: Edited on the server, par: Different local database, stop: Drops open orders)
- A server can be added or removed at any hour, a release is a numbered artifact that can be undone, and a new developer can run a copy on day one. (config: In environment variables, state: In a shared datastore, rel: Build, release, run, par: Same kind of database, stop: Finishes, then exits)
- Add a server with no code change
- Pick every rowNoYes
- Undo a bad release in minutes
- Pick every rowNoYes
- Release in business hours without losing orders
- Pick every rowNoYes
- A new developer runs a copy on day one
- Pick every rowNoYes
An example
A restaurant-ordering company ran its app on two servers, and the head of engineering dreaded Friday evenings. Demand doubled at dinner time, and adding a third server needed a night's work: database passwords sat inside the code, and diners' sessions lived in one server's memory, so a new machine logged half of them out. Releases were edits made by hand on the live servers. Nobody could say what exactly was running, and the one engineer who knew was often away.
The team agreed to apply twelve rules from a published methodology, starting with three. Settings moved out of the code into each environment, sessions moved into a shared store, and every release became a numbered package built once and installed as is. Within a quarter a third server took ten minutes to add, a bad release was reversed in the same time, and a new hire ran a full copy of the system on day one.
The core idea
The methodology treats an application as something that should run the same way anywhere and be handled by routine. It gives twelve factors: one codebase tracked in version control, explicit dependencies, configuration kept in the environment, backing services attached like plug-in resources, strictly separate build, release, and run stages, stateless processes, services exported through port binding, scaling out through concurrent processes, disposable processes that start fast and stop cleanly, development and production kept alike, logs treated as a stream of events, and administrative tasks run as one-off processes.
The insight sits under the list. Each rule removes a reason for a deployment to be special. When code, settings, and state are cleanly separated, the same build can go to a laptop, a test environment, or production, and a failure in any one process is cheap because another can take its place.
The thinking behind it
Adam Wiggins The Twelve-Factor App is credited to Adam Wiggins and traces to Heroku, the platform-as-a-service company where it began in 2011. The site's own account of its aims is plain: apps that a new developer can set up quickly, that move cleanly between environments, that suit cloud deployment, that stay close to production while in development, and that scale without major changes. The twelve rules read as constraints that make unlike applications behave alike. In November 2024 the methodology was released as an open source project.
Where it sits in the layers
The twelve factors are placed in Layer 8, Methodologies and Operating Systems, as a prescriptive method for one kind of work. They take for granted the layers above them: that software should change often and safely, chiefly the improvement philosophy of Continuous Delivery in Layer 6. They are put to work through the engineering practices of Layers 9 and 10, such as the deployment pipeline and the on-call review. They are also what a platform engineering group builds into its templates. The common mistake is asking them to decide architecture or strategy. They describe how one application should behave in production and say nothing about which applications the company should build.
How organizations put it to work
A platform or architecture group usually owns the factors, with each service team accountable for its own app. The first step is an audit: each service is checked against the twelve, and the gaps are ranked by how much they cost. The factors then enter the organization as templates and checks. New services start from a template that already follows them, and a pre-deployment check fails any build with settings in the code or a hard-coded database address.
The measures are concrete: the time to stand up a new environment, how often each service deploys, and how long a rollback takes. Teams do not rewrite working systems to comply. They bring each service into line when they next touch it, and spend more effort on the factors that block scaling or releases.
Sustaining it takes someone who reviews exceptions, because drift is quiet. In the first year, expect uneven progress, a few older systems that stay exceptions, and arguments about statelessness where an app truly needs local data. The business gains a routine, repeatable path to production and relies less on the engineer who knows how things are wired.
Where it goes wrong
The most common failure is treating the twelve as a legal code. Teams spend months making a stable internal tool comply, and the work buys nothing. The sign is compliance reports that rise while deployment speed does not change.
Close behind is applying them where they do not fit. The method assumes web-style apps run as disposable processes on a platform, and it fits poorly with systems that must keep large amounts of state in memory or with older software that cannot be split. The sign is workarounds that pile up around one factor.
Last is age. The text was last updated in 2017, and the practices around it have kept moving, so a team that follows the letter of a factor may be following advice a current review would question. The sign is a design review that cites the factor as its only reason.
Related and rival frameworks
- Continuous Delivery and Continuous Deployment. The wider practice of keeping software always ready to release. Pick it when the question is the pipeline and the release rhythm.
- Platform Engineering. A team that builds paved roads so that every service follows rules like these without thinking about them. The better pick when many teams must adopt the same habits.
- DevOps. The culture and collaboration that lets developers and operators share responsibility for production, which the factors assume and do not create.
Go to the source
- The Twelve-Factor App, 12factor.net (last updated 2017), 2011