Backing Services and Build-Release-Run Factors
What you'll learn: How the Twelve-Factor App methodology treats external services and separates the deployment lifecycle into distinct, immutable stages.
Understanding Backing Services
A backing service is any service your application consumes over the network—databases, message queues, email services, caching systems, or third-party APIs. The Twelve-Factor App treats these as attached resources, meaning your application shouldn't care whether a service is local or remote, managed by you or a vendor.
Think of backing services like electrical outlets: your application plugs into them via configuration (connection strings, credentials), but doesn't need to know whether the power comes from solar panels on your roof or a distant power plant. This allows you to swap a local database for a cloud-hosted one simply by changing configuration—no code changes required.
The Build-Release-Run Separation
The deployment lifecycle must be strictly separated into three stages:
-
Build: Convert source code into an executable bundle (artifact). This includes compiling, bundling dependencies, and asset compilation.
-
Release: Combine the build artifact with environment-specific configuration to create a ready-to-execute release. Each release gets a unique identifier (timestamp, version number).
-
Run: Execute the release in the target environment.
These stages flow in one direction only. You never modify code in production or mix configuration into the build. If something needs changing, you create a new release—never patch the running system directly.
This separation ensures reproducibility: release v47 will always behave identically whether run today or next month, because it's an immutable combination of a specific build and specific configuration.
Key Takeaway: Treat external services as swappable resources controlled by configuration, and maintain strict separation between building code, combining it with configuration, and running it—never blur these stages or modify releases after creation.