What are the twelve factors that define a good web-app?
Source: https://12factor.net/
- Codebase: One codebase tracked in revision control, many deploys
- Dependencies: Explicitly declare and isolate dependencies
- Dependency declaration and isolation must always be used together.
- Config: Store config in the environment
- An app’s config is everything that is likely to vary between deploys (staging, production, developer environments, etc).
- The twelve-factor app stores config in environment variables
- Backing services: Treat backing services as attached resources
- A backing service is any service the app consumes over the network as part of its normal operation.
- The code for a twelve-factor app makes no distinction between local and third party services. To the app, both are attached resources, accessed via a URL or other locator/credentials stored in the config.
- Build, release, run: Strictly separate build and run stages
- Processes: Execute the app as one or more stateless processes
- Twelve-factor processes are stateless and share-nothing.
- Port binding: Export services via port binding
- This is typically implemented by using dependency declaration to add a webserver library to the app
- The contract with the execution environment is binding to a port to serve requests.
- Concurrency: Scale out via the process model
- Twelve-factor app processes should never daemonize or write PID files. Instead, rely on the operating system’s process manager (such as Upstart, a distributed process manager on a cloud platform, or a tool like Foreman in development) to manage output streams, respond to crashed processes, and handle user-initiated restarts and shutdowns.
- Disposability: Maximize robustness with fast startup and graceful shutdown
- Dev/prod parity: Keep development, staging, and production as similar as possible
- The twelve-factor developer resists the urge to use different backing services between development and production.
- Logs: Treat logs as event streams
- Each running process writes its event stream, unbuffered, to stdout.
- Admin processes: Run admin/management tasks as one-off processes
More resources:
- The Twelve Factor app: Best Practices for Java Deployment by Joe Kutner (https://www.youtube.com/watch?v=94PxlbuizCU)