The Twelve-Factor app is a methodology for apps that use declarative formats, have a clean contract, are suitable for modern cloud platforms, minimize divergence, and can scale up without significant changes. According to IBM’s Daniel Berg, the 12 factors are directly related to the same principles for developing apps with the microservices architecture.
The Twelve-Factor app was published by Heroku co-founder Adam Wiggins in 2011 based on the development, operation and scaling witnessed on the Heroku platform. “Twelve Factor apps are built for agility and rapid deployment, enabling continuous delivery and reducing the time and cost for new developers to join a project. At the same time, they are architected to exploit the principles of modern cloud platforms while permitting maximum portability between them. Finally, they can scale up without significant changes to tooling, architecture or development practices,” the Heroku team wrote in a post.
Recently, with the rise of microservices, the 12 factors have started to become more popular because it aligns with the microservices principle, according to Pivotal’s Lawrence Crowther.
The 12 factors are “a triangulation on ideal practices for app development, paying particular attention to the dynamics of the organic growth of an app over time, the dynamics of collaboration between developers working on the app’s codebase, and avoiding the cost of software erosion,” the methodology states.
According to its website, the 12 factors are:
- One codebase tracked in revision control, many deploys
- Explicitly declare and isolate dependencies
- Store config in the environment
- Treat backing services as attached resources
- Strictly separate build and run stages
- Execute the app as one or more stateless processes
- Export services via port binding
- Scale out via the process model
- Maximize robustness with fast startup and graceful shutdown
- Keep development, staging and production as similar as possible
- Treat logs as event streams
- Run admin/management asks as one-off processes
Crowther suggests those starting on a microservices journey from scratch should strictly follow the 12 factors if they wish to gain agility and the ability to scale. However, if they are taking a legacy monolithic application and transitioning it to a microservice, it will be harder to adhere to those 12 factors. Over time, companies can start introducing or improving the codebase more in line with the 12 factors, Crowther explained.
“The 12 factor apps check-list is really just a set of guidelines that dictate how a microservice should be built to properly support the concept of independently managed and iterated services. These factors are important when building decoupled, stateless microservices,” said Matt Ellis, product management and strategy architect at TIBCO.