Why you need it
The app passes every check on the test server, then fails the moment it reaches production. The app did not change. The servers were different all along, and the test only proved it works on a server you are not using.
Think of it like this
Practising a speech in a quiet room, then giving it on a windy stage with a microphone that cuts out. Rehearse on the same kind of stage, and what worked in practice works on the night.
Where you’ll find it
- Heroku: Pipelines move the exact build that ran on staging up to production, onto the same kind of machine.
- Kubernetes: Kustomize keeps one shared set of settings, with a small, visible list of what each environment changes.
- Terraform: Modules let test and production be built from the same file, called twice.
What to know first
Built from code. A server's settings are written in a file, so the same file gives the same server. See Infrastructure as code.
One sealed box. The app is built once and the same box goes to every server. See Build once, deploy many.
Environment. One full place the app runs: test, staging or production, each with its own servers.
How it works
- The box is not the problem. The same box passes on test and fails in production. If the box is the same, the difference must be in the servers. This is the first beat of the animation.
- Look at the settings. Test has
memory: 4 GB. Production has 2 GB. If the app needs 3, it runs out of memory only in production. These are the two strips in the animation. - Build both from one code. Write the setting once, in
main, and build both servers from it. Now the strip on test and the strip on production are the same row. This is environment parity. - Keep the gaps small and written down. Some things must differ, like the size of the database or the web address. Keep that list short and in the code, never made by hand. Press "set production up by hand" in the animation to see one hand change break it again.
An example
The app needs 3 GB of memory. Test was set up with 4 GB, production with 2 GB, by different people a year apart.
Every test passes. On release, production runs out of memory within a minute, and the team spends an evening rolling back.
With both built from memory: 4 GB in one file, the test server is a true preview: if it passes there, it has the same room in production.
Further reading
- Dev/prod parity, The Twelve-Factor App. One short page on the three gaps between test and production, and how to close them. Start with this one.
- Deployment automation, DORA. Research on why using the same steps for every environment makes releases safer.
- Declarative management using Kustomize, Kubernetes docs. A real way to share one set of settings and write down only the differences.