DEV Community

Michael Di Prisco
Michael Di Prisco

Posted on • Edited on

The Twelve Factor App Methodology: A Beginner's Guide

The twelve factor app methodology is a set of best practices for building modern, cloud-native applications. It was created by Adam Wiggins and is widely regarded as a standard for building scalable, reliable, and maintainable software applications. In this article, I will introduce you to the twelve factors that are essential for building an effective cloud-native application.

1. Codebase

A single codebase is the first factor that a twelve-factor app should have. The idea behind this is to keep the codebase under version control and to have only one codebase per application. Multiple applications should not share the same codebase.

2. Dependencies

The second factor is the dependencies. The app should declare and isolate all its dependencies. This allows for better reproducibility and portability.

3. Config

Configuration should be stored in the environment. This makes the application easily configurable for different environments, such as development, staging, and production.

4. Backing services

Backing services, such as databases, queues, and caches, should be treated as attached resources. The application should not make assumptions about the location of these resources and should be able to easily replace them.

5. Build, release, run

Build, release, and run should be kept separate. This allows for better control over the lifecycle of the application.

6. Processes

The application should be designed to run as one or more stateless processes. This enables scalability and resilience.

7. Port binding

The application should be self-contained and should not rely on runtime injection of a web server. It should be able to run on any port.

8. Concurrency

Concurrency is an important aspect of scalability. The application should be able to scale horizontally by adding more instances.

9. Disposability

The application should be designed to be disposable. This means that it should start up fast and shut down gracefully.

10. Dev/prod parity

The development, staging, and production environments should be as similar as possible. This ensures that there are no surprises when deploying the application to production.

11. Logs

The application should generate logs as event streams. This allows for better debugging and monitoring.

12. Admin processes

The final factor is the ability to run administrative tasks as one-off processes. This allows for tasks such as database migrations or backups to be easily performed.

Conclusion

The twelve factor app methodology is a set of best practices that can help you build modern, cloud-native applications that are scalable, reliable, and maintainable. By following these guidelines, you can ensure that your application is built to run on any cloud platform, and that it can be easily deployed and managed.

P.S. Like and comment if you want to know more about this topic!

Top comments (5)

Collapse
 
cnastasi profile image
Christian Nastasi

It's always a good thing to talk about those topics.

But why not add some examples of how to implement every case?

For example, you can specify that NPM for Javascript and Composer for PHP are pretty good examples of how to solve point 2, and so on.

Collapse
 
cadienvan profile image
Michael Di Prisco

It's a good idea, I wanted to keep it tech-agnostic, that's why I didn't mention examples!

Collapse
 
cnastasi profile image
Christian Nastasi

I understood your point. Just, referring to existing and well-known solution help people to understand how to apply those concepts.

And also that they are not so far or difficult to reach but the most modern frameworks already adopted some of them

Thread Thread
 
cadienvan profile image
Michael Di Prisco

I'll try to improve this post and let it become a series with examples ;)

Collapse
 
phlash profile image
Phil Ashby

Thank you for the reminder - I've not seen 12-factor apps mentioned for a while 😄

For anyone interested, Adam Wiggins original site is here: 12factor.net/ (and it's open source!)