Systems & Backend

Twelve-Factor App

A set of 12 principles for building cloud-native apps that are portable, scalable, and disposable.

The Twelve-Factor App is a set of twelve principles for building software-as-a-service apps that are portable and scale cleanly on modern cloud platforms. Key factors: strict config in the environment (not code), treat backing services as attached resources, separate build/release/run, keep processes stateless, and design for disposability (fast startup, graceful shutdown).

Worked example: a twelve-factor app reads its database URL from an environment variable (not a checked-in config file), stores no session state on disk (so any instance can be killed or added freely), and logs to stdout as an event stream — so it drops cleanly into containers and autoscaling. Gotcha: the factors codify what makes an app cloud-friendly, and violating them bites later — config in code blocks reuse across environments, local state breaks horizontal scaling, and slow startup breaks autoscaling and rolling deploys — so they are less rules than a checklist for “will this behave in the cloud?”