TWELVE FACTOR APP


Twelve-Factor application refers to a set of twelve separate guidelines formulated by developers at Heroku. It is considered significant in the software development landscape because it recommends the best practices to build portable and resilient applications.

It's a set of criteria to help you measure how friendly an app is to really run in a platform. When you build apps to be 12-factor compliant, you have some confidence that it is going to run well in a cloud set of infrastructure. Here they are:

1. Codebase.

Each application is tracked in a codebase in some sort of revision control. You might have more than one instance of that software in different environments, but you have that one sort of codebase to go back to.

2. Dependencies.

An app calls out its dependencies, instead of depending on them just being there in the target environment. We've all built software in the past that assumed things were running on that Windows machine or Linux machine and you kind of tap into that.
A 12-factor app brings along its dependencies because it doesn't know what's there and doesn't want to depend on it. 

3. Configuration.

The configuration refers to anything that differs among the environments; think connection strings and feature flags. In this idea, they're injected via operating system environment variables. Now you might not like environment variables, but this can also really mean an externalized configuration that you might reference something in source control and something with an actual change history. 
The idea is pulling configuration out of your code and putting it into some sort of remote store if it's the environment or a remote configuration store. 

4. Backing Services.

Things like databases, message queues, they're treated as attached resources, not some sort of embedded tightly coupled resource

5. Build, release, run.

This makes it easier to swap when changing environments. You've got separate built-in run stages, the idea is that the stage to build the artefact before deploying it and operating it, are all separate stages of processing. 
It doesn't all happen in the same place.

6. Processes.

Apps executing as stateless processes. So make sure there's nothing in-between the app instances, all the state is outside the app process itself. 

7. Port Binding.

The services are exported as port bindings. Really, the idea here is that the application is kind of self-contained and any services are exposed via ports like HTTP.

8. Concurrency.

Horizontal scalability. So you can scale-out via processes. You don't make bigger processes, rather, you scale-out to more and more of them, a very cloud-native concept.

9. Disposability.

What this really means is an application should start quickly and shut down gracefully. This is necessary when you think of quick autoscaling or failure recovery. If it takes me 10 minutes to start up my app, it really doesn't work well for an autoscaling environment that by the time I've scaled, maybe the incident's over. And same with failure recovery. 
If I have to assume that instances can disappear when something gets rebooted or restarted, I have to know that I haven't somehow corrupted my application. So I want to build apps for disposability.

10. Development and Production Parity.

Automation and continuous delivery helps you keep all your environments in sync. So you don't end up with this "works on my machine" classic developers/operators problem. 

11. Logs. 

Instead of log files, logs are a stream, they get collected, they get aggregated, analyzed, much different than just logging into an individual machine and looking at a log file or an event log on a Windows box. Instead, it's a different way to think about processing logs at scale. 

12. Admin Processes.

You think of admin processes like migrating a database or things like that. When you run these long-running processes scripts, what have you is, you run the environments identical to the one that's running the app itself. 

So this is one set of patterns, the 12-factor apps, there are other patterns which we will take a look at while making reference to this pattern in subsequent posts. Thanks for reading.

Video Episode

Post a Comment

If you can't commemt, try using Chrome instead.