Created by the engineers at Heroku, the 12-Factor App is a set of best practices for building modern, cloud-native applications that are portable, resilient, and ready to scale in environments like Azure, AWS, or Kubernetes.
Factor 10 states that your local environment should be as close as possible to production. This is why we use Docker Composeβto ensure the exact same DB version and OS version follow the code from the developer's laptop to the production cluster.
Q: "Why is 'Statelessness' the most important of the 12 factors for scaling?"
Architect Answer: "Because it allows for **Elasticity**. If your app stores user sessions in the RAM of the local server, you are stuck with that server. If you add a second server, the user might hit server B and 'lose' their login. By moving state to a backing service like Redis or a Database, any server instance can handle any incoming request. This allows you to scale from 1 instance to 10 instances in seconds without killing active user sessions."