Learn / Infrastructure / Lesson 09

Deploys and versioning

Most outages start with a change. How to ship so that old and new code never mix, and why a bad release should reach a few machines before it reaches all of them.

Last updated: 2026-09-19

What it is

A deploy replaces running code with new code. For a web app that means the server process, and also every file the browser downloads: HTML, CSS, JavaScript. For a moment, old and new exist side by side. Most deploy failures happen in that moment.

Why it is a rule

Neither was an attack. Both were one release reaching every machine, unchecked, at once.

How to do it

One build, every machine

Build once and ship the same artifact everywhere. A server that was "updated by hand" is how Knight's eighth server kept its old code.

Version every asset with the deploy

html
<script src="/app.js?v=9f3c2e1"></script>

Rewrite every local asset URL to carry the deploy id. Then:

Tell open tabs a new version exists

A tab left open for a day is running yesterday's code against today's server. Push the current version id over a socket; when it changes, offer a reload instead of letting the old code keep sending requests the new server may not understand.

Roll out in stages

Check at boot, fail loudly

The new process checks that its secrets, database and required files exist before it takes traffic. A process that boots with a missing secret should refuse to start, not serve errors quietly.

How we do it here

Every local asset URL on every page carries the deploy id, and page composition happens once per deploy. The server announces its version over a socket so open tabs know when to reload. Boot checks for missing secrets, and the edge cache is purged when the new process comes up.

Benefits

Disadvantages

Checklist

Sources

Read this lesson as Markdown