DEV Community

Carlos Loredo
Carlos Loredo

Posted on

SaaS: The Twelve-Factor app methodology explained

The Twelve-Factor App methodology is a methodology for building software-as-a-service applications. These best practices are designed to enable applications to be built with portability and resilience when deployed to the web.

To understand this methodology we can divide the twelve factors into 3 key components:
Next, we'll see the best practices that you should follow for every factor to comply with what this methodology says.

Code Factors:

Factor 1 - CodeBase:


  • Code must be tracked in a version control system (VCS) like Github, BitBucket, etc.
  • One-to-One relationship between the CodeBase and the application.
  • There can be multiple deploys of the application.
  • Different versions of the CodeBase can be in each deployment.

Factor 5 - Build, release and run:


  • Build: Transform a CodeBase into an executable unit called build.
  • Release: Combine build with configuration so that it's ready to run.
  • Run: Runs the application.

Factor 10 - Dev/Prod parity:


  • Minimize differences between deployment and production environments.
  • Back-end services should be the same across environments (dev/prod)

Deploy Factors:

Factor 2 - Dependencies:


  • Be aware that an app is only reliable as its least reliable dependency.
  • Be sure that code explicitly declares any dependency.

Factor 3 - Config:


  • Config contains everything that varies between deploys such as credentials and backing services locations.
  • Configs must be kept separate from the code
  • Store config in environment variables.

Factor 4 - Backing services:


  • Applications should not distinguish between local and third-party back-end services.
  • All services should be accessed by URL and credentials so that can be swapped without changing the code.

Factor 6 - Processes:


  • Stateless and share nothing.
  • Backing services store persistent data since memory and filesystems are not shared across processes.
  • Data is centrally stored.

Factor 7 - Port binding:


  • Export services by port binding. HTTP and other services are exported in this way.
  • To bind a port usually you must declare a web server library.
  • Applications can be backing services for other applications.

Factor 9 - Disposability:


  • Applications should have minimal process start-time and graceful termination.
  • Quickly deploy code and configure changes.
  • Easily scale applications.

Factor 11 - Logs:


  • Applications should not concern themselves with storing logs.
  • Applications should trend logs as event stream written to stdout.
  • Execution environment captures the stream for all apps aggregates the logs and routes logs to their destination.

Operate Factors:

Factor 8 - Concurrency:


  • Concurrent processes can be used to scale the application.
  • Stateless processes can be spun up without creating dependencies on other processes.

Factor 12 - Admin processes:


  • Enable one-off application management processes such as database migration.
  • Run against a release using the same CodeBase configuration.
  • Are included in the application code.


  • The Twelve-Factors Methodology website: 12factor

Top comments (1)

endymion1818 profile image
Ben Read

This is so much clearer to understand than the website you referenced ... thank you!