Checking how many agents are working

How this works
Kontakt
← Blog
A steel control lever with three labeled positions on a dark bench, the middle position lit with a thin amber light, and the AMARBARO mark engraved on the panel.
✎Blogbeitrag

How a site update goes live without breaking it

The short version

A rehearsal on a copy finds problems the live site would show to visitors, and the way to trust it is to say what the copy does and does not stand for.

What this is about

Changing a live website is like changing a tire while the car is moving. You can do it, but you do not want to find a problem after the wheel is off. Our routine has three parts: rehearse the change on a copy, deploy it, and check the result from outside. This article walks through those parts and tells about one rehearsal that caught a real problem.

Why it matters

A site has visitors at all hours. A broken update means lost orders, lost trust and a rushed night for you. The cost of a rehearsal is a few minutes. The cost of a bad deploy can be much more. Even if you run a tiny site, a rehearsal habit pays back the first time it catches something.

How to do it, step by step

1. Make a copy that looks like production

Our rehearsal starts from a copy of the live database. It then starts the new version of the app next to the old one. The point is that the test uses real data and the same kind of setup. A test with made up data hides problems that real data would show.

2. Walk the pages and compare

We run what we call a metadata walk. It asks for every public address we can list, on both the old site and the new one, and records for each address whether the answers match. Differences are either a failure or an allowed difference with a written reason.

3. Deploy with a safety net

The deploy script builds the new image, ships it, starts the app container and then checks two addresses. Both must answer 200 within 60 seconds. If either does not, the script returns to the previous image tag on its own. In our runbook for one switch, the planned downtime was about 15 seconds, because the app container is recreated and a data migration runs in that window.

4. Check from outside

After the deploy we ask the live site for pages through its public name, the way a visitor would. A local check from inside the machine can pass while the public path is broken, and we cover that in the article on how we know a site is up.

The rehearsal that found a missing folder

Here is what happened on one of our shop sites. The first walk failed two addresses. Both were under the gallery uploads folder. The old site answered 200 for each. The new one answered 404, not found.

The data itself was fine. The copy of the database had all its rows, and the counts matched. What was missing was the folder of uploaded photos. The rehearsal container had no uploads volume, so the files were simply not there.

The obvious fix was to attach the live uploads folder to the test container. We had two ways to do it, and both were wrong.

  • Read only. The new app's start script tries to change the owner of the uploads folder when it starts. On a read only folder, that fails, and the container crashes before the walk can run.
  • Read and write. The ownership change works, and it changes the owner of the real production files. A test would then leave the live site with different ownership. That is a change to production made by a rehearsal.

So we made a scratch copy of the volume, attached that, and let the start script do its work on the copy. The walk then passed with 41 URLs, no failures and 28 allowed differences. The 28 matched the allowed count in the earlier record for the same site. When it was done we removed the copy, the container and the scratch volume. The live stack was never touched.

What the rehearsal did not prove

We are careful about this. The scratch copy has the same files as production as of the copy. It has whatever owners and permissions the copy kept. So the walk tested the copy's permissions, not production's. The question whether the start script's ownership change would pass on the real folder with its real owners was left open. We have not run it there, because the rule is that a rehearsal never touches production.

That is the honest limit of any rehearsal. It is a model of the live site. It is a good one, and it catches a lot, but it is still a model.

A short checklist you can copy

  1. Copy the data before you change anything.
  2. Start the new version beside the old one.
  3. Compare the same list of addresses on both.
  4. Write down every allowed difference, and why.
  5. Deploy with an automatic return to the old version.
  6. Check from outside, with a real fetch.
  7. Write down what the rehearsal could not test.

Words you may not know

  • Deploy: put a new version of a site into use.
  • Rehearsal: a practice run on a copy.
  • Volume: a folder kept outside a container.
  • Rollback: going back to the last good version.
  • Migration: a planned change to the shape of the database.
  • 404: the code for "not found".
  • Ownership: which user account a file belongs to.

Try it

  1. Take a small site you run. Write a list of five addresses that must always work.
  2. After the next change, fetch each one with curl -s -o /dev/null -w '%{http_code}' and check you get 200.
  3. See the kinds of sites we ship this way at amarbaro.com/web.

Kommentare

Noch keine Kommentare.

Anmelden um zu kommentieren.