Skip to content
All tags

#postgres

12 entries tagged #postgres

  • How Does Facebook's Distributed Like Counter Work?

    Post · Oct 01, 2026

    A celebrity posts and a million people tap the heart in ten minutes, and every one of them sees a count that seems to keep up. One row with a number in it can't take that. So what does?

  • Transactional Outbox: Two Systems, One Commit

    Post · Sep 28, 2026

    Save to the database, then publish an event: two lines, two systems, and nothing that makes them agree. What happens when the process dies in between, and why every obvious fix still leaves a gap.

  • Two Writes, One Row: Who Wins?

    Post · Sep 26, 2026

    Two requests read the same row, both do their maths, both write back. One of them silently disappears. How the system should resolve that isn't one answer: it depends on whether the write is a delta, a quick piece of logic, or a human edit made minutes after the read.

  • What Breaks From 1k to 1M Requests Per Second

    Post · Aug 11, 2026

    One product-page endpoint, the same code, ten times more traffic, then ten times more again. Each step breaks something different, and the last one breaks something extra capacity can't fix.

  • Migrating Schema-Per-Tenant Databases at Scale

    Post · Jul 24, 2026

    Give each tenant its own schema and you get real isolation. You also get two new problems: knowing where each tenant lives, and running one migration correctly five hundred times instead of once.

  • Designing Multi-Tenant APIs That Scale

    Post · Jul 18, 2026

    One app, many customers, one WHERE clause keeping them apart. Forget it once and nothing crashes: tenant A just sees tenant B's invoices. How to make isolation something the system enforces, not something engineers remember.

  • Why Payment Retries Need Idempotency Keys

    Post · Jul 12, 2026

    You tap your card, the machine freezes, you tap again. Were you charged twice? An HTTP payment endpoint faces the same question on every retry, and without an idempotency key it gets it wrong.

  • Size a System on the Back of an Envelope

    Cheat · Sep 20, 2026

    The interviewer asks how much traffic you're expecting. Round to powers of ten, turn per-day into per-second, and end every number on the design decision it forces: one node, a cache, or a shard.

  • Cut a Slow N+1 Query Down

    Cheat · Aug 16, 2026

    An endpoint that queries once per parent row instead of once per request looks fine with ten rows and falls over with ten thousand. Batch the per-row lookups into one query and the round trips disappear.

  • Make a Write Endpoint Safely Retryable

    Cheat · Jul 01, 2026

    A client that retries a POST after a timeout can create the resource twice or charge a card twice. An idempotency key lets the server spot the retry and replay the first response instead of doing the work again.