The 12 Factor App is a methodology for building software-as-a-service (SaaS) applications that are portable, scalable, and resilient. It emphasizes best practices for development, deployment, and operations, resulting in applications that are easier to manage and maintain over time.
1. Codebase:
- A single codebase for all environments (development, staging, production)
- Version control system used (e.g., Git)
- Shared dependency management (e.g., npm)
![](http://blog.kinkars.com/wp-content/uploads/2023/12/image-2.png)
2. Dependencies:
- Explicitly declared dependencies in a manifest file
- Dependencies easily installed and managed
- Isolated from system libraries
![](http://blog.kinkars.com/wp-content/uploads/2023/12/image-3.png)
3. Config:
- Store configuration in environment variables
- Configurations kept separate from code
- Environment-specific configurations
![](http://blog.kinkars.com/wp-content/uploads/2023/12/image-4.png)
4. Backing services:
- Treat backing services as resources (e.g., databases, queues, caches)
- Configure services through environment variables
- Services are interchangeable
![](http://blog.kinkars.com/wp-content/uploads/2023/12/image-5.png)
5. Build, release, run:
- Strict separation of build, release, and run stages
- Build scripts create a clean build
- Release scripts prepare artifacts for deployment
![](http://blog.kinkars.com/wp-content/uploads/2023/12/image-6.png)
Processes:
- Treat applications as sets of independent processes
- Processes run on a container platform
- Processes scale horizontally
![](http://blog.kinkars.com/wp-content/uploads/2023/12/image-7.png)
7. Port binding:
- Applications listen on a port assigned at runtime
- No dependence on a specific port number
- Enables multiple instances to run on the same system
![](http://blog.kinkars.com/wp-content/uploads/2023/12/image-8.png)
8. Concurrency:
- Applications are stateless and can be scaled horizontally
- State is managed by backing services
- Processes handle multiple requests concurrently
![](http://blog.kinkars.com/wp-content/uploads/2023/12/image-9.png)
9. Disposability:
- Processes can be started and stopped quickly
- Graceful shutdown and restart
- Zero downtime deployments
![](http://blog.kinkars.com/wp-content/uploads/2023/12/image-10-1024x431.png)
10. Dev/prod parity:
- Development, staging, and production environments are identical
- Ensures consistent behavior across environments
- Easier to test and deploy changes
![](http://blog.kinkars.com/wp-content/uploads/2023/12/image-11.png)
11. Logs:
- Treat logs as event streams
- Log everything and forward to a central log aggregator
- Logs used for debugging and monitoring
![](http://blog.kinkars.com/wp-content/uploads/2023/12/image-12-1024x353.png)
12. Admin processes:
- Admin processes are separate from web processes
- Run ad-hoc tasks
- Do not interfere with the normal operation of the application
![](http://blog.kinkars.com/wp-content/uploads/2023/12/image-13.png)
Benefits of the 12 Factor App:
- Portability: Applications can be easily deployed to different platforms and environments.
- Scalability: Applications can be easily scaled horizontally to handle increased traffic.
- Resilience: Applications are resistant to failures and can recover quickly.
- Maintainability: Applications are easier to maintain and manage over time.
- Collaboration: The methodology encourages collaboration between developers working on the same codebase.
Further Resources:
- The official 12 Factor App website: https://assets.ctfassets.net/9n3x4rtjlya6/xah6YxrHHMYaO4wIGCY2O/3b2a5b943ce4346daef9fda1c200067f/Ian_Cooper_12-factor_apps_in_.NET.pdf
- A blog post by Heroku on the 12 Factor App: https://blog.heroku.com/twelve-factor-apps
- A talk by Adam Wiggins about the 12 Factor App: https://m.youtube.com/watch?v=N_g8KWEUN5s
![](http://blog.kinkars.com/wp-content/uploads/2023/12/image-14.png)
Comments
![Share on Facebook facebook](http://blog.kinkars.com/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/facebook.png)
![Share on Twitter twitter](http://blog.kinkars.com/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/twitter.png)
![Share on Reddit reddit](http://blog.kinkars.com/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/reddit.png)
![Pin it with Pinterest pinterest](http://blog.kinkars.com/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/pinterest.png)
![Share on Linkedin linkedin](http://blog.kinkars.com/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/linkedin.png)
![Share by email mail](http://blog.kinkars.com/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/mail.png)
Leave a Reply