2023-12-03 21:49:01
The 12 Factor App is a methodology for building scalable and maintainable web applications. It provides a set of guidelines for developing modern, cloud-native, and containerized applications. Here are the 12 factors explained in bullet points:
1. Codebase:
- One codebase per application.
- Use version control to manage code changes.
2. Dependencies:
- Explicitly declare and isolate dependencies.
- Avoid relying on system-wide packages.
3. Config:
- Store configuration in environment variables.
- Keep configuration separate from code.
4. Backing Services:
- Treat external services (databases, caches, etc.) as attached resources.
- Connect to them via URLs or environment variables.
5. Build, Release, Run:
- Strictly separate the build, release, and run stages of the application.
- Use consistent and repeatable build processes.
6. Processes:
- Execute the application as stateless processes.
- Avoid storing session data locally; use external services.
7. Port Binding:
- Export services via a port and communicate over the network.
- Web applications should bind to a port defined by the environment.
8. Concurrency:
- Scale out via the process model.
- Utilize multiple stateless processes to handle requests.
9. Disposability:
- Maximize robustness with fast startup and graceful shutdown.
- Terminate unneeded processes without impact.
10. Dev/Prod Parity:
- Keep development, staging, and production environments as similar as possible.
- Use the same dependencies and configuration.
11. Logs:
- Treat logs as event streams.
- Write application logs to standard output and allow log aggregation.
12. Admin Processes:
- Run administrative tasks as one-off processes.
- Use the same codebase and environment for administrative tasks.
Adhering to these 12 factors helps create applications that are easier to develop, deploy, and maintain, making them well-suited for cloud-native and containerized environments.
15.6K views18:49