Skip to content

Instantly share code, notes, and snippets.

@lambda-mike
Last active August 14, 2020 17:52
Show Gist options
  • Save lambda-mike/9ddee2628e79f8c55fd458822f3f7307 to your computer and use it in GitHub Desktop.
Save lambda-mike/9ddee2628e79f8c55fd458822f3f7307 to your computer and use it in GitHub Desktop.
12 Factor apps - my notes

12 Factor Apps

12 Factor Apps

I. Codebase

Multiple apps sharing the same code is a violation of twelve-factor. The solution here is to factor shared code into libraries which can be included through the dependency manager.

II. Dependencies

A twelve-factor app never relies on implicit existence of system-wide packages. It declares all dependencies, completely and exactly, via a dependency declaration manifest.

If the app needs to shell out to a system tool, that tool should be vendored into the app.

III. Config

Apps sometimes store config as constants in the code. This is a violation of twelve-factor, which requires strict separation of config from code. Config varies substantially across deploys, code does not.

The twelve-factor app stores config in environment variables (often shortened to env vars or env).

IV. Backing services

The code for a twelve-factor app makes no distinction between local and third party services.

V. Build, Releas, Run

The twelve-factor app uses strict separation between the build, release, and run stages.

Releases are an append-only ledger and a release cannot be mutated once it is created.

VI. Processes

Execute the app as one or more stateless processes.

Twelve-factor processes are stateless and share-nothing.

VII. Port binding

Export services via port binding.

The twelve-factor app is completely self-contained.

VIII. Concurrency

Scale out via the process model

IX. Disposability

Maximize robustness with fast startup and graceful shutdown.

X. Dev/prod parity

Keep development, staging, and production as similar as possible.

The twelve-factor developer resists the urge to use different backing services between development and production.

XI. Logs

Treat logs as event streams.

A twelve-factor app never concerns itself with routing or storage of its output stream.

XII. Admin processes

Run admin/management tasks as one-off processes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment