Featured
Every upstream call spends money and quota. A layered defence of validation, rate limits, caching, single-flight and leases keeps both under control.
15 min
Topic 03 / 08 · 09 articles
About this topic
117 words
Backend systems fail in boring, repeatable ways: a message is delivered twice, a retry charges a customer again, a third-party API rate-limits you at the worst possible moment. The fixes are rarely clever — they are disciplined.
Here I write about the patterns that make services correct under real-world conditions: idempotent consumers for at-least-once queues, dead-letter topics as a safety net, protecting paid upstream APIs with validation, caching and locks, and using one schema to drive validation, types and API documentation at the same time.
The examples are in TypeScript on Node.js, usually with Fastify and Google Cloud Pub/Sub, but each article explains the underlying idea first so you can apply it in whatever stack you run.
Featured
Every upstream call spends money and quota. A layered defence of validation, rate limits, caching, single-flight and leases keeps both under control.
15 min
· 11 min
A practical split for small teams: coarse per-client limits at the edge, per-user and per-cost limits in the service, and the 429 behaviour both must share.
11 min
· 9 min
Ordering keys give per-key order and take away parallelism. Learn what they guarantee, how one failure stalls a key, and when versioned events are a better fix.
9 min
· 11 min
Payment webhooks arrive twice, late and out of order. A handler that verifies, stores, acknowledges fast and applies effects idempotently, shown with Stripe.
11 min
· 11 min
A feature-flag vendor is more than a small team needs. One Firestore document, a short in-memory cache and safe defaults give you kill switches and rollouts.
11 min
· 12 min
Define each request and response shape once. Get runtime validation, compile-time types and the OpenAPI document from the same object, with CI to prove it.
12 min
· 13 min
Per-service path fragments, a small Node generator that enforces the rules humans forget, and a CI check that keeps the API Gateway config honest.
13 min
· 13 min
A dead-letter queue turns a stuck message into a ticket instead of an outage. How to set one up on Pub/Sub, alert on it, and replay safely after a fix.
13 min
· 13 min
Pub/Sub will deliver some messages twice, and that is by design. Here is how to build consumers whose side effects happen once anyway, with working code.
13 min
· 15 min
Every upstream call spends money and quota. A layered defence of validation, rate limits, caching, single-flight and leases keeps both under control.
15 min