Guide collection

Reliability

Retries, caches, timeouts and failure reports for software that tells the truth when things break

10 guides in this collection

Performance

Never Cache a Failure

"There is none" and "I could not ask" are different answers. Cache the first, retry the second, and keep them as different types so the code cannot mix them up.

3 min read
Guide

Atomic File Writes

Write to a temporary file beside the target and rename it into place. A reader then sees the whole old file or the whole new one, never half of either.

3 min read
Guide

Single-Flight: Run Shared Setup Once

When twenty requests all need the same slow setup, let the first one do it and the other nineteen wait for the same promise.

3 min read
Guide

A Timeout on Every Outbound Call

A request with no timeout waits for ever, and it holds a page open while it waits. Set a deadline on every call, and never make a page wait for a slow lookup.

3 min read
Guide

Only the Newest Request May Set State

Responses can arrive out of order. Number each request, and let a response update the screen only if no newer request has started since.

3 min read
Data

Idempotency Belongs in the Database

Webhooks and jobs are delivered more than once. Make the duplicate impossible with a unique index, and claim the work in a single statement.

3 min read
Data

Retry With Backoff, Jitter, and a Dead Letter

Record the work before you call out. Retry transient failures with a growing, randomised delay, stop on permanent ones, and hand what is left to a person.

3 min read
Guide

Say What Actually Failed

A wrong diagnosis on screen is worse than a blank one. Classify the failure, show the upstream's own words, and never draw a zero where the truth is unknown.

3 min read
Deployment

Exit Code Zero Is Not "Delivered"

curl exits 0 on a 403, and a pipeline reports the status of its last command. Mark work as done only inside a branch that checked the real result.

3 min read