Back to blog

From commit to production in one hour: what has to be true?

Thắng Đoàn
Thắng Đoàn

Once a week, on Friday evening, a FotoFlow developer builds the app on a laptop, copies it to the production server over SSH and restarts it while everyone stays late. This Friday the laptop had a newer library than the server, the app will not start, and the site is down while someone works out which of thirty changes to undo. There is no record of exactly what ran before, so even rolling back is guesswork. Four hours pass.

Continuous integration

The fix starts with a rule: every push to the shared repository starts a pipeline on a clean machine, which builds the code and runs the test suite from the previous part. Nothing depends on anyone's laptop. Small changes merge into main several times a day, and a red pipeline means "stop and fix this first," so main always builds and passes. Big, rare releases feel safer and are the opposite: the more that changes at once, the harder it is to test, blame and undo. Keep the pipeline under ten minutes or people start batching again.

Build once, promote the artifact

The pipeline's last stage packages the result into one immutable artifact, a container image tagged with its commit, foto-api:3f9c2a1, and pushes it to a registry. That exact image is what gets tested, deployed to staging and then to production; only configuration differs between environments. What you tested is what you ship: build once, promote the same artifact. Rebuilding for production can pull different dependencies and produce a different program. Every green image deploys to staging automatically, where smoke tests watch the main journeys, so production is one button press away.

Release without betting the site

Blue-green runs two identical production groups: blue serves everyone while green warms up with the new version, then the load balancer switches all traffic at once, and a bad release is undone by switching back in seconds. Canaries go softer: 5 percent of real traffic sees the new version, its error rate and latency are compared with the old, and a worse canary rolls back automatically before most users ever meet it. That is testing in production, the only environment with real users and real data.

What this does not solve

A schema change can still break everything: v42 renames a column, name to full_name, and during the rollout the servers still on v41 ask for a column that no longer exists. The pattern is expand and contract: add the new column and write both, backfill, switch reads over, and only drop the old column when no running version uses it. And a green pipeline says the code works, not that the feature is good: the new feed design deploys dark, behind a feature flag, seen first by the team, then 1 percent of users, then everyone, with rollback being a setting rather than a deploy. Deploying and releasing are two separate decisions. Remove each flag once its feature is fully out, or the code fills with branches nobody dares delete. The DORA metrics, deploy frequency, lead time, failure rate and time to restore, keep score: the teams that ship most often also break production least.

Your last deploy: how long from "merge" to "live", and how long to undo it if it were bad?
A migration renames a column while old servers still run. Which order of steps keeps both versions working?

Code now travels safely from commit to production. Next: zooming out and writing the design down. Next in the series: Draw the system twice: why one sketch is never enough?

Sources

Martin Fowler: Continuous Integration

Google SRE Books

Martin Fowler: Test Pyramid

Share:

Recommended for you

Enjoyed this article?

Subscribe for new articles. No spam. Unsubscribe anytime.

No pasting. This is the challenge.0/200

Typed live, never pasted.