Skip to content
CodeBrewerz logoCodeBrewerz
Engineering blog

How the Machinery Actually Works

Long-form engineering writing with diagrams you can poke at. No launch posts and no listicles: one system per article, taken apart until the surprising part is obvious.

Start here

Cloud

What Is Serverless, Really? The Honest Cost, Limits and Payoff

Serverless is not "no servers". It is a usage based renting a system that bills on usage milliseconds rather than by the hours provisioned. Here are the pros and cons and hard limitations.

8 min readRead the post
10-part series

System Design Deep Dives

Token bucket, sliding window, and the distributed implementation nearly everyone writes first — which lets through roughly twice the limit under concurrency, silently, and only at scale.

  1. 1Rate Limiting: Every Algorithm, and the Race Condition in the Obvious OneToken bucket, sliding window, and the distributed implementation nearly everyone writes first — which lets through roughly twice the limit under concurrency, silently, and only at scale.8 min read
  2. 2Building a News Feed: Fan-Out on Write, on Read, and Why You End Up Doing BothEvery feed design is one question — do you do the work when someone posts, or when someone looks? Both answers are wrong at the extremes, which is why every large platform runs a hybrid.7 min read
  3. 3A Payments Ledger: Why It's Append-Only, and What Idempotency Keys Actually ProtectA balance column is the wrong data structure for money. Here is the double-entry ledger that replaces it, and the retry semantics that stop a network timeout from charging someone twice.7 min read
  4. 4Caching in Front of a Database: Invalidation Is the Easy HalfThe hit ratio is arithmetic and the eviction policy barely matters. What actually pages you is the moment one hot key expires and every in-flight request becomes a database query at the same instant.9 min read
  5. 5Queues and Logs: "Exactly Once" Is a Property of Your Handler, Not Your BrokerThe broker cannot deliver exactly once and no vendor page will tell you that plainly. Here is what the guarantees actually mean, why a log is a different product from a queue, and where the duplicates come from.9 min read
  6. 6Sharding a Database: The Key You Pick Is the One Decision You Cannot Undo CheaplySplitting a table across machines is easy. Choosing what to split it on decides your skew, your query fan-out and your migration cost simultaneously — and the obvious keys are wrong in three different ways.8 min read
  7. 7Typeahead: The Only Feature Whose Deadline Is Set by the User's HandsSearch-as-you-type is not a search problem with a lower latency target. The deadline is the next keystroke, which means the answer has to exist before the question is asked.8 min read
  8. 8Building Chat: "Sent" Is Four Different Facts and the Tick Only Shows OneThe transport is the easy part. What makes a messaging system hard is that a recipient is several devices, ordering cannot come from anyone's clock, and every checkmark is a claim you have to be able to defend.7 min read
  9. 9Video Streaming: You Are Not Serving a File, You Are Serving Six Thousand of ThemThe upload is a job queue, the playback is a control loop, and the delivery is somebody else's network. Here is what actually happens between someone pressing upload and someone else pressing play.8 min read
  10. 10Matching Riders to Drivers: The Index Is Easy, the Write Rate Is NotFinding the nearest driver is a solved problem. Doing it while every driver moves every four seconds, at a cell boundary, without two riders being promised the same car — that is the system.7 min read
2-part series

Context Engineering

Prompt engineering is what you write. Context engineering is everything else the model sees — and the window is a budget you spend against space, cost and attention at once.

  1. 1Context Engineering: The Window Is a Budget, Not a ContainerPrompt engineering is what you write. Context engineering is everything else the model sees — and the window is a budget you spend against space, cost and attention at once.10 min read
  2. 2Context Engineering: History, Tool Output, and What to MeasureRetrieval is the context you choose. Conversation history and tool results are the context that arrives whether you look at it or not — and together they are usually the bigger half.10 min read

Everything else we have written