4. The Twelve-Factor App
● Software is many times delivered as SaaS applications
● 12FA is a methodology for building SaaS that:
○ Uses declarative formats for setup automation;
○ Maximizes portability;
○ Enables deployments on cloud platforms;
○ Embraces continuous deployment;
○ Scales up painlessly.
● Not only for Devs or DevOps people...
5. I. Codebase
One codebase tracked in revision
control, many deploys
All the code resides in a source control system.
Doesn’t matter which one, but there has to be
one.
Importance: Non-negotiable. Everyone does this.
Period.
6. Be explicit. Never assume dependencies will be
in place on a given machine. No guesswork, state
everything as it needs to be.
Importance: High. Prevents teams from constant
confusion and frustration.
II. Dependencies
Explicitly declare and isolate
dependencies
7. Store all configuration data in a separate place
from the code, and read in by the code at
runtime.
Importance: Medium. Many people don’t do this,
but don’t be sloppy.
III. Config
Store config in the environment
8. Reference each service by just an endpoint. Not a
single piece of code should care where these are
actually running.
Importance: High. Is there any reason not to
adhere to this best-practice?
IV. Backing Services
Treat backing services as attached
resources
9. Build stage deals with the burden, being
managed by developers. Run stage is simple,
battle-tested and just works. Yes, like a charm.
Importance: Conceptual. Defined by used
frameworks and tooling.
V. Build, release, run
Strictly separate build and run
stages
10. The state of the system is completely defined by
your databases and shared storage, and not by
each individual running application instance.
Importance: High. Stateless apps are robust,
easier to manage, have less bugs, and scale better.
VI. Processes
Execute the app as one or more
stateless processes
11. Application also interfaces to the world using a
simple URL. Usually this comes for free when it
is being presented through a web-server.
Importance: Medium. It’s a clean way to work,
but it’s generally not hard to change later.
VII. Port binding
Export services via port binding
12. Let lots of little processes handle specific needs;
working independently and running separately.
Just Adding more resources will do the magic.
Importance: Low. Don’t worry about this until
you get deep into scaling considerations.
VIII. Concurrency
Scale out via the process model
13. Application should have everything it needs
waiting in high-speed databases or caches, so it
can start up snappily.
In case it crashes, it should always be able to
start back up cleanly.
Importance: Medium. You may not have to
worry about it, but understand its implications..
IX. Disposability
Maximize robustness with fast
startup and graceful shutdown
14. Keep local development environment as close as
possible to production. Often accomplished by
making use of a tool like Vagrant or Docker.
Importance: Medium. Devs will take shortcuts if
their local environment works “well enough”.
X. Dev/prod parity
Keep development, staging, and
production as similar as possible
15. In production, logs should be automatically
captured as a stream of events and pushed into a
real-time consolidated system.
Importance: Low. You are overlooking better
solutions if logs are your primary forensic tool.
XI. Logs
Treat logs as event streams
16. Run one-off admin tasks from an identical
environment as production.
Importance: High. Having console access to a
production system is critical. No excuses here.
XII. Admin processes
Run admin/management tasks as
one-off processes
17. At the heart of a happily running system, there is always a robust, reliable, not that much surprising architecture.
● The Twelve Factor are based on the experience on a wide variety of SaaS apps in the wild;
● Most important industry players are adopting The Twelve Factors in their platforms and frameworks architectures;
● To overlook The Twelve Factors does not sound like a clever choice.
The Twelve-Factor App - Summary
18. The Twelve-Factor App - Next Steps
● Discuss these Twelve Factors with the development team, see if there is room for improvement based on any of them.
● Beyond the Twelve-Factor App - Exploring the DNA of Highly Scalable, Resilient Cloud Applications
12factor.net