Skip to content

12 Factor Applications

This is a summarized version of the well-established 12 factor applications concept from the DevOps world, sorted by importance.

Non-negociableπŸ”—

1. The codebaseπŸ”—

Use the source control, Luke.

The app should have a single codebase tracked in a revision control system. Many deploys are possible, but they should all originate from the same codebase.

High ImportanceπŸ”—

2. DependenciesπŸ”—

Explicitly declare and isolate dependencies.

Without this, the team will have a constant slow time-suck of confusion and frustration multiplied by the size and number of applications.

3. Backing servicesπŸ”—

Treat backing services as attached resources.

Reference backing services by a simple, cluster-wide endpoint. (like an URL, or a domain name)

The code shouldn't know the difference between a backing service hosted in a different data center, or SaaS, managed, etc.

4. ProcessesπŸ”—

Execute the app as one or more stateless processes.

Try to keep the state (persistence layer) of your app completely defined by your databases and shared storage, and not by each individual running app instance.

Stateless apps are more robust, easier to manage, incur fewer bugs and scale better.

5. Admin processesπŸ”—

Run admin/management tasks as one-off processes.

Not sure about this one, it does not seem to have aged well.

MediumπŸ”—

6. ConfigπŸ”—

Store configuration in the environment.

Configuration should vary between different environments, but code shouldn't.

Ergo, try to store configuration data separate from the code and have the code read it at runtime.

7. Port bindingπŸ”—

Expose services via port binding.

As an extension to the "Backing services" principle, the app itself should also interface with the outside world via a simple URL.

Different purposes should be mapped to different domain names (for example: authenticated, rate-limited public APIs vs. internal APIs)

8. DisposabilityπŸ”—

Maximize robustness with fast startup and graceful shutdown.

New versions of the application should ideally launch right away and start to handle traffic. Also, there shouldn't be any mandatory "cleanup" tasks required after application shutdown.

LowπŸ”—

9. Production / development parityπŸ”—

Keep dev, staging and production environments as similar as possible.

This minimizes the risk of unexpected behaviour upon entering production. Virtualization usually helps.

10. ConcurrencyπŸ”—

Scale out via the process model.

Specific needs should be handled by lots of little independent processes. This means each concerned can be scaled separately as needed.

11. LogsπŸ”—

Treat logs as event streams.

In production, logs should be captured as a stream of events and pushed into a real-time consolidated system for long-term archival and data-mining.

ConceptualπŸ”—

12. Build, release, runπŸ”—

Strictly separate build and run stages.

Keep the "run" stage simple and bullet-proof. The "build" stage should do all the heavy lifting.


Last update: 2020-04-13