Practice : Twelve-Factor App
Purpose and Strategic Importance
The Twelve-Factor App methodology defines a set of principles for building modern, scalable, and maintainable web applications. Originating from Heroku, these principles support best practices for software-as-a-service (SaaS), cloud-native development, and DevOps automation.
Following these factors helps teams standardise deployments, reduce operational overhead, and improve portability and resilience - enabling faster delivery and better long-term sustainability.
Description of the Practice
The twelve factors include:
- Codebase – One codebase tracked in version control, many deploys.
- Dependencies – Explicitly declare and isolate dependencies.
- Config – Store configuration in the environment.
- Backing Services – Treat backing services as attached resources.
- Build, Release, Run – Strictly separate build and run stages.
- Processes – Execute the app as one or more stateless processes.
- Port Binding – Export services via port binding.
- Concurrency – Scale out via the process model.
- Disposability – Fast startup and graceful shutdown for robustness.
- Dev/Prod Parity – Keep development, staging, and production as similar as possible.
- Logs – Treat logs as event streams.
- Admin Processes – Run admin/management tasks as one-off processes.
How to Practise It (Playbook)
1. Getting Started
- Audit existing applications for alignment with the twelve factors.
- Start by externalising config, declaring dependencies, and using environment variables.
- Refactor code to ensure stateless processes and clean separation of build and run stages.
- Implement logging practices that stream logs to stdout/stderr or observability tools.
2. Scaling and Maturing
- Build pipeline automation around build-release-run separation.
- Use containers (e.g. Docker) to standardise dev/prod parity and disposability.
- Run applications behind load balancers with health checks for resiliency.
- Use process-level scaling for horizontal elasticity.
- Consolidate monitoring and alerting across backing services and app logs.
3. Team Behaviours to Encourage
- Treat infrastructure as ephemeral and restartable.
- Focus on portable deployment practices that reduce vendor lock-in.
- Maintain a shared understanding of each factor and its trade-offs.
- Document architectural decisions based on adherence to the twelve principles.
4. Watch Out For…
- Config baked into code or source control.
- Shared state across processes (e.g. session data not externalised).
- Manual admin tasks tightly coupled with application logic.
- Long-lived processes that don’t shut down gracefully.
5. Signals of Success
- Applications are portable across environments and cloud platforms.
- Deployment pipelines are consistent, automated, and reliable.
- Failures are isolated, recoverable, and observable.
- Applications scale predictably under load.
- Teams confidently build, test, and release independently.