---
title: "Twelve-factor app"
slug: "twelve-factor"
category: "glossary"
tags: ["glossary", "coding", "twelve-factor", "deployment", "architecture"]
status: "stable"
last_updated: 2026-05-14
summary: "Twelve-factor app is a methodology for portable web services: declared dependencies, externalized config, stateless processes, and disposable workers."
related:
  [
    "[[coding/general-principles]]",
    "[[file-organization/config-files]]",
    "[[ops/vercel]]",
    "[[ops/cloudflare]]",
    "[[backend/observability]]",
    "[[backend/migrations]]",
  ]
---

## Overview

This page is the atomic definition. The broader principles live at [[coding/general-principles]].

## Definition

The twelve-factor app is a methodology of twelve rules for building portable, deployable web services, published by the Heroku team in 2011. The rules are: 1) Codebase, 2) Dependencies, 3) Config, 4) Backing services, 5) Build/release/run, 6) Processes, 7) Port binding, 8) Concurrency, 9) Disposability, 10) Dev/prod parity, 11) Logs, 12) Admin processes. The central themes are declared dependencies, externalized config (in environment variables), stateless processes, and treating attached services as resources. Modern PaaS providers like Vercel, Fly.io, and Railway assume twelve-factor compliance.

## When it applies

Apply twelve-factor rules to any web service that runs on a PaaS, in containers, or behind a load balancer. Most rules still apply to serverless functions; processes are even more disposable there.

## Example

A FastAPI service reads its database URL from `DATABASE_URL` (factor 3: config), logs to stdout instead of files (factor 11: logs), and exits cleanly on `SIGTERM` within 10 seconds (factor 9: disposability). The same image runs locally, in staging, and in production with no code changes.

## Related concepts

- [[coding/general-principles]] - the broader principles that include twelve-factor.
- [[file-organization/config-files]] - the externalized-config rule in practice.
- [[backend/observability]] - the logs-as-event-streams rule in practice.
- [[ops/vercel]] - a PaaS that assumes twelve-factor compliance.
- [[backend/migrations]] - admin processes as one-off runs against production.

## Citing this term

> See [[glossary/twelve-factor|Twelve-factor app]] (llmbestpractices.com/glossary/twelve-factor).

## Related

- [[coding/general-principles]]
- [[file-organization/config-files]]
- [[backend/observability]]
- [[ops/vercel]]
- [[backend/migrations]]
