Twelve-Factor App
Originated at Heroku
The Twelve-Factor App is a methodology of twelve best practices for building software-as-a-service applications that are portable, scalable, and easy to deploy consistently across environments, from codebase management to configuration to…
Definition
The Twelve-Factor App is a methodology of twelve best practices for building software-as-a-service applications that are portable, scalable, and easy to deploy consistently across environments, from codebase management to configuration to logging.
Overview
The methodology was published by engineers at Heroku, drawing on patterns observed across many cloud applications, and it codified a set of practices that has since become a baseline reference for building cloud-native software. Its twelve factors cover the full application lifecycle: a single tracked codebase per app, explicitly declared dependencies, configuration stored in environment variables rather than in code, backing services treated as attached resources, a strict separation between build, release, and run stages, and processes that are stateless and share nothing. Several factors map directly onto practices covered elsewhere in the DevOps toolkit: treating logs as event streams rather than managing log files is the philosophy behind modern log aggregation systems, and the emphasis on disposable, quickly-startable processes underpins both container orchestration and immutable infrastructure. The 'config' factor — never storing secrets or environment-specific values in code — is now considered baseline security and portability practice, especially for applications deployed via Infrastructure as Code (IaC). While the twelve factors predate Kubernetes and modern container tooling, they remain widely referenced as design guidance for microservices because the underlying goals — portability across environments, horizontal scalability, and resilience to individual process failure — are exactly what container platforms like Kubernetes are built to support.
Key Concepts
- One codebase tracked in version control, deployed to many environments
- Explicitly declared and isolated dependencies rather than assumed system packages
- Configuration stored in environment variables, strictly separate from code
- Backing services (databases, queues, caches) treated as interchangeable attached resources
- Strict separation of build, release, and run stages
- Stateless, share-nothing processes that can be started, stopped, or scaled freely
- Logs treated as event streams rather than files the app manages itself
- Fast startup and graceful shutdown to support elastic scaling and quick deploys