Blog
Practical notes from an AI engineer: prompts you can copy, free tools worth testing, how new models behave, and the System Design Mastermind series. Search, or pick a topic.
37 of 42 posts
AI coding agent system design (Claude Code, Cursor, Codex): context, edits, sandboxes and evals
How to design an AI coding agent in real interview order, across three product shapes (inline autocomplete, an interactive agent in the terminal or IDE, and background agents in cloud sandboxes that open pull requests): Tab requests per second, tokens per agent session with and without prompt caching, and containers at peak as the numbers that matter, an API with cancellable autocomplete, text-anchored edits and permission requests, an explainer on where an autocomplete's 300 ms go, the design built in passes, one bug fix walked from keystroke to merged PR, a lab on finding the right code (grep vs an embedding index vs both), a lab on applying edits (whole file, line numbers, search/replace, unified diff, a fast apply model), a lab on sandboxes and warm pools, evals (SWE-bench Verified, Terminal-Bench, pass^k), cost per task, prompt vs train, and what happens when each part fails.
LLM evaluation and guardrails platform system design: judges, guard latency, paired eval gates and safe rollouts
How to design an evaluation and guardrails platform for every LLM feature in a company, in real interview order: guard checks per second, judge calls a day and eval examples per run as the numbers that matter, an AI gateway API with versioned configs and structured block events, an explainer on what an LLM judge's score really means (sensitivity, specificity and the correction), input and output guards, traces, graders, datasets, online scoring and release gates built in passes, one support request walked from guards to a regression test and a canary, a lab on whether an eval can see a regression (set size, pairing, judge quality), a lab on guards on the hot path (latency, false blocks, misses, cost and exposed tokens), rollouts, online scoring, prompt vs fine-tune, and what happens when each part fails.
Recommendation system design (TikTok-style For You feed): candidates, ranking, freshness and A/B tests
How to design a recommendation system and feed ranker in real interview order: requests per second, heavy-ranked candidates per second and events per second as the numbers that matter, a feed API with a request_id on every event, an explainer on two-tower retrieval and approximate nearest-neighbour indexes, candidate sources, a light and a heavy multi-task ranker, a value model and final re-rank built in passes, one request walked from tap to page, a like, the next page reacting, the training join and a new ranker shipping, a lab on the funnel (recall against GPUs and milliseconds), a lab on freshness (when the model learns a new item and how fast the feed reacts), offline evals, interleaving, A/B test sizing, LLM judges and their limits, cost per request, guardrails, and what happens when each part fails.
Content moderation pipeline system design: hash matching, classifiers, LLM checks and human review at a billion items a day
How to design a content moderation pipeline (posts, images, video and chat) in real interview order: items per second, prevalence, LLM calls and reviewer-hours as the numbers that matter, a moderation API with a time budget, decisions as events, reports and appeals, an explainer on perceptual hash matching, hash lists, classifiers, an LLM policy check, a decision engine with two lines per policy, a priority review queue and a decision log built in passes, one meme walked from upload to removal, copies, an appeal and a new model, a lab on thresholds, base rates and the review band, a lab on reach and the review queue over a day, evals, LLM judges, shadow and canary rollouts, cost per tier, prompt vs fine-tune, guardrails, and what happens when each part fails.
Payment system design (Stripe): idempotency, unknown outcomes, the ledger and reconciliation
How to design a payments platform like Stripe in real interview order: calls held open on slow banks, the platform's own fee account and the money in 0.01% as the numbers that matter, an API with amounts in cents and an Idempotency-Key on every POST, an explainer that turns a $100 payment into fees and double-entry journal entries, a card vault, payments API, risk engine, gateway, outbox, event log, ledger, webhooks, reconciliation and payouts built in passes, one $60 payment walked from checkout to the merchant's bank, a lab on timeouts and retries that charge twice or take money without an order, a lab on hot ledger accounts with sub-accounts and batching, a reconciliation lab that finds two real breaks among the noise, the lifecycle of a payment, and what happens when each part fails.
Notification system design: push, email and SMS without spam, drops or duplicates
How to design a notification platform (push, email, SMS and an in-app inbox) in real interview order: transactional sends, devices and one marketing campaign against FCM's 600K-a-minute quota as the numbers that matter, an API that returns 202 with an idempotency key and takes categories instead of channels, an explainer on how a push reaches a locked phone, a Notify API, router, preferences and tokens, channel queues with a transactional lane, push and email/SMS workers built in passes, one order update walked from the order service to Riya's phone with a dead tablet token, a lab on a 180M-send campaign, priority lanes, 429s and pacing, a lab on retries, collapse ids, idempotency keys and dead tokens, a decision walker for opt-ins, caps and quiet hours, the lifecycle of a notification, and what happens when each part fails.
Offline GPU batch inference system design: millions of LLM calls by a deadline, on GPUs that can vanish
How to design an offline batch inference pipeline (a nightly job that runs an LLM over 10 million rows) in real interview order: GPU-hours, the deadline and the shared prompt prefix as the numbers that matter, an API of files, jobs, custom_ids and results in any order, an explainer on what prefix caching saves, a validator, scheduler, shard queue, GPU workers on spot capacity, per-attempt files and a finalizer built in passes, one job walked through a lost spot node, a row that crashes the engine and a prompt change, a lab on rows in flight, KV memory, cost and the deadline, a lab on shard size, preemption, duplicates and poison rows, evals with golden sets, judges and canary shards, cascades, prompt vs fine-tune, guardrails, and what happens when each part fails.
Ad click aggregator system design: exactly-once counts, late clicks and hot ads
How to design an ad click aggregator (Google Ads, Meta, Uber Ads) in real interview order: the dollar cost of a counting error and rows per minute as the numbers that matter, a signed click URL and a redirect that waits on one log append, a click service, Kafka log, Flink aggregator, fraud filter, OLAP store, budget counter and nightly recount built in passes, one click walked from the tap to the bill, an explainer from raw clicks to billable ones, a lab on where duplicates come from and which fix catches which, a lab on watermarks, allowed lateness and budget pacing, a lab on hot ads and salted keys, and what happens when each part fails.
News feed system design: fan-out, celebrities and ranking
How to design a social news feed (Facebook, Instagram, X, LinkedIn) in real interview order: timeline inserts and the biggest account as the numbers that matter, a light API that posts before fan-out and pages by cursor, a post store, social graph, fan-out queue, timeline cache, feed service and ranker built in passes, one post walked from upload to a follower's screen, a lab on the celebrity threshold between push and pull, an explainer on how a ranked feed scores two posts, a lab on ranking inside a latency budget, a demo of offsets vs cursors while new posts arrive, where deletes and blocks are enforced, and what happens when each part fails.
AI agent platform system design: tools, durable runs, approvals and agents you can trust
How to design a platform that runs many teams' tool-using AI agents, in real interview order: tokens per run, concurrency and cost as the numbers that matter, an API with 202 run ids, approvals for exact arguments and versioned tools, an explainer on what tool definitions cost, a durable orchestrator, tool gateway, user-scoped credentials, approvals and a sandbox built in passes, one refund run walked end to end through a crash and an injected instruction, a lab on the loop's tokens, time and reliability, a lab on crashes, idempotency keys and parked runs, evals with end states and pass^k, LLM judges, rollouts, the lethal trifecta, prompt vs tools vs fine-tune, and what happens when each part fails.
Kafka system design: a distributed log that never loses an acknowledged message
How to design a distributed message queue like Kafka in real interview order: bytes times replication and fan-out as the numbers that matter, a light API of produce, fetch, group heartbeat and commit, partitions, leaders, in-sync followers, controllers and consumer groups built in passes, one record walked from send() to a committed offset, a lab on acks, min.insync.replicas and who can become leader, a lab on partitions, hot keys and broker network and disk, a lab on consumer-group rebalances and duplicates, and what happens when each part fails.
Ticketmaster system design: selling seats without double-booking
How to design Ticketmaster in real interview order: one hot onsale as the number that matters, a light API with separate hold and pay steps, an edge, a waiting room, a booking service and a seat inventory built in passes, one booking walked from queue to ticket, a lab on two fans racing for one seat, a lab on the onsale surge and the waiting room's admission rate, a lab on how long to hold a seat, and what happens when each part fails.
RAG assistant over company docs system design: retrieval, permissions and answers you can trust
How to design a RAG assistant over company documents in real interview order: corpus, churn and tokens per question as the numbers that matter, an API with identity from SSO and citations as data, an explainer on hybrid search and reciprocal rank fusion, ingestion and serving built in passes around a versioned index, one question walked from Slack to a cited answer, a lab on retrieval quality against tokens, latency and cost, a lab on permission filters and freshness, evals, LLM judges, rollouts and guardrails, and what happens when each part fails.
Metrics and logging system design (Datadog-style): series, roll-ups and alerts you can trust
How to design a Datadog-style metrics and logging platform in real interview order: series and log bytes as the numbers that matter, batched ingest that answers 202 only once durable, agents, intake, a durable log, writers, a tag index and a compressed time-series store built in passes, one point walked from a counter to a graph and a page, a lab on tags, cardinality and churn, a lab on roll-up tiers and how much of your logs to index, a lab on alerting when data arrives late, and what happens when the monitoring system itself fails.
WhatsApp system design: chat, offline delivery and the three ticks
How to design WhatsApp in real interview order: connections and device copies as the numbers that matter, a light API over one long-lived connection, chat servers, a session registry and per-device offline queues built in passes, one message walked from send to read, a lab on acks, retries and duplicates behind the ticks, a lab on the reconnect storm after a lost zone, a lab on group and multi-device fan-out with end-to-end encryption, and what happens when each part fails.
LLM serving platform system design (ChatGPT-style): tokens, GPUs and safe model changes
How to design a ChatGPT-style LLM serving platform in real interview order: the numbers in tokens, a streaming API with token-based limits, a router that picks model, version and a replica with the conversation's prefix cached, one message end to end, conversations and the KV cache, a lab on GPUs, batching and cost per request, a lab on bursts and admission control when GPUs take minutes to add, evals, LLM judges, canary rollouts and guardrails, and what happens when each part fails.
AI foundations: inference, RAG and agents
Foundations F18. What every AI feature in a system-design round runs on: tokens, prefill and decode, TTFT and time per token, GPU memory and the KV cache, continuous batching, quantization, prefix caching, model routing and speculative decoding, embeddings and vector search, retrieval-augmented generation, agents and tool calling, evaluation with eval sets and LLM judges, and guardrails against prompt injection. Each idea is told as a story you'll remember, with a lab that shows how many users one GPU can serve and what each token costs.
Data pipelines: batch and stream
Foundations F17. The system behind every dashboard, fraud check and report: batch vs stream, MapReduce and Spark and the shuffle, data lakes, warehouses and lakehouses on Parquet, change data capture and schema evolution, event time, windows and watermarks, late data, state, checkpoints and exactly-once, Lambda vs Kappa and reprocessing, and orchestration, backfills and data quality. Each idea is told as a story you'll remember, with a lab that shows how long a pipeline should wait for late events.
Distributed job scheduler system design: on time, at least once, never lost
How to design a distributed job scheduler (cron at scale) in real interview order: the numbers and the top-of-the-hour peak, the job and run API with time zones, sharded schedulers with leases, one run end to end, the claim query with a unique run key, a lab on the top-of-the-hour herd, a lab on leases, heartbeats and retries, and what happens when each part fails.
Search, feeds and geo building blocks
Foundations F16. The parts inside Twitter, Swiggy search, typeahead and "find nearby": the inverted index and text analysis, BM25 and two-stage ranking, vector and hybrid search with HNSW and reciprocal rank fusion, scaling a search cluster with shards, replicas and refresh, typeahead with precomputed top-k per prefix, feed fan-out on write vs read, assembling and paging a feed with cursors, and geo indexes (geohash, S2, H3, quadtrees). Each idea is told as a story you'll remember, with a lab that shows when push, pull or hybrid fan-out breaks.
Security essentials for system design
Foundations F15. What to say when the interviewer asks "how do you secure this?": authentication and password storage, sessions vs signed tokens and how to revoke them, OAuth 2.0 and OpenID Connect, authorization and least privilege (BOLA is still #1), TLS 1.3, mTLS and zero trust, envelope encryption, keys and secrets, injection, XSS, CSRF and SSRF, and edge defence against DDoS and abuse. Each idea is told as a story you'll remember, with a lab that shows how long a stolen token keeps working and what checking it costs.
Observability and safe deployments
Foundations F14. What to say when the interviewer asks "how would you know it's broken?" and "how do you ship changes safely?": metrics, logs and traces and what each is for, the four golden signals, SLIs, SLOs and error budgets, burn-rate alerts that page only when users hurt, canary releases with automated analysis, rolling and blue-green deploys with rollback-safe schema changes, feature flags and why config is a deploy, and incident response with blameless postmortems. Each idea is told as a story you'll remember, with a lab that prices one bad change in error budget.
Reliability and disaster recovery
Foundations F13. What to say when the interviewer asks "what happens when this dies?": availability maths for chains and copies, failure domains, cells and shuffle sharding, timeouts and retries with backoff and jitter, circuit breakers and bulkheads, health checks and failover, static stability, backups vs replication with RPO and RTO, and the four disaster-recovery strategies and why you drill them. Each idea is told as a story you'll remember, with a lab that splits a year's downtime into its sources.
Scaling and performance
Foundations F12. What to say when the interviewer asks "how does this scale?": throughput vs latency and why targets are percentiles, why latency explodes as servers near 100% busy, how fan-out turns a rare slow call into the common case, scaling up vs out with stateless servers, why ten servers aren't ten times faster, finding the bottleneck and making each request cheaper, what autoscaling can't do, and how to shed load under overload. Each idea is told as a story you'll remember, with a lab that shows p99 rising with utilisation, fan-out and a surge.
Idempotency, exactly-once and sagas
Foundations F11. What to say when the interviewer asks "the call timed out and the client retried: did you charge twice?" and "payment worked but the courier booking failed: now what?": why a timeout is an unknown, operations that are idempotent by design, idempotency keys done properly, idempotent consumers, what exactly-once really means, two-phase commit and why services avoid it, sagas with compensations, and how to order a saga's steps and keep it alive through crashes. Each idea is told as a story you'll remember, with a lab that compares 2PC and a saga on a hot item and counts the refunds and double charges.
Rate limiter system design: fair limits at a million requests a second
How to design a rate limiter for a public API, in real interview order: numbers, API and headers, the gateway design, one request end to end, Redis keys and the atomic script, picking the algorithm, counting across hundreds of nodes, and what happens when the limiter itself fails.
Queues and event streams
Foundations F10. What to say when your design has an arrow labelled "queue" or "Kafka": why a queue goes in the middle (load levelling and decoupling), task queues vs event logs and pub/sub, partitions, keys and ordering, delivery guarantees and what "exactly-once" really covers, retries and dead-letter queues, backpressure and consumer lag, the transactional outbox, and commands vs events when picking a broker. Each idea is told as a story you'll remember, with a lab that shows when a queue absorbs a spike, when partitions cap the fix, and when retries eat the capacity.
Coordination: clocks, leaders, locks and consensus
Foundations F09. What to say when your design needs "one leader", "a lock" or "run this once": why wall clocks lie, ordering events with Lamport and hybrid clocks (and Spanner's TrueTime), failure detection and leader election without split brain, leases, fencing tokens, distributed locks for efficiency vs correctness, consensus and Raft, and where consensus belongs in a real design. Each idea is told as a story you'll remember, with a lab that shows how timeouts, pauses and fencing decide whether a failover is fast, slow or harmful.
Consistency, CAP and quorums: what replicas promise
Foundations F08. What to say when the interviewer asks "CP or AP?": linearizable vs eventual, read-your-writes and causal consistency, CAP stated precisely (and what's a simplification), PACELC and the latency cost of strong reads, quorums with N, W and R, where quorums leak (sloppy quorums, hinted handoff, repair), concurrent writes (last-writer-wins, versions, CRDTs) and choosing consistency per piece of data. Each idea is told as a story you'll remember, with a lab that shows overlap, latency and what happens when copies are cut off.
Caching: hit ratios, invalidation and stampedes
Foundations F07. What to say after you draw the cache box: why the hit ratio decides everything, where caches live, cache-aside and read-through, write-through vs write-behind vs delete-on-write, TTLs and invalidation (and the race that leaves stale data), LRU and LFU eviction and sizing, stampedes when a hot key expires, and hot keys and cold caches. Each idea is told as a story you'll remember, with a lab that turns cache size, popularity and TTL into a hit ratio, database load and herd size.
Replication and sharding: copying and splitting your data
Foundations F06. What to say when one database machine isn't enough: leader and followers, synchronous vs asynchronous replication, replication lag and read-your-writes, failover without split brain, multi-leader and leaderless quorums, range vs hash shard keys, consistent hashing with virtual nodes and fixed slots, and hot keys and cross-shard queries. Each idea is told as a story you'll remember, with a lab that sizes shards and shows what moves when you add a machine.
Databases: data models, indexes and transactions
Foundations F05. What every design's database step needs: the relational model, the NoSQL families, B-trees vs LSM-trees, composite and covering indexes, ACID and the write-ahead log, isolation levels and their anomalies, the last-seat race, and choosing a database out loud. Each idea is told as a story you'll remember, with a lab that prices five index choices for one query.
APIs and real-time communication: REST, gRPC, retries, webhooks and live updates
Foundations F04. The contract between client and server: REST and HTTP semantics, when to pick GraphQL or gRPC, cursor pagination, idempotency keys and backoff, versioning, polling vs SSE vs WebSockets, webhooks, and holding millions of open connections. Each idea is told as a story you'll remember, with a lab that prices poll against push.
Back-of-envelope estimation: from users to servers in one minute
Foundations F03. Turn "500 million users" into requests per second, peak load, storage, bandwidth, in-flight requests, servers and cache size, with round numbers and the latency figures worth memorising. Each idea is told as a story you'll remember, with a lab where every number picks a design decision.
The interview framework: requirements, numbers and scope before boxes
Foundations F02. How a 45-minute system-design round is shaped, which questions to ask first, how to turn "fast" and "reliable" into numbers, which data must never be wrong, what to leave out, and how the requirements choose your deep dives. Each idea is told as a story you'll remember.
How a request travels: DNS, load balancers, gateways and open connections
Foundations F01. Follow one request from a tap on the phone to the database and back, and learn each building block as a story you'll remember: DNS, TCP and TLS, CDNs, load balancers, API gateways, service discovery, real-time connections and multi-region routing.
Uber system design, reverse-engineered: from tap to pickup
How Uber turns a ride request into an assigned driver, walked through in real interview order: numbers, API, high-level design, one request end to end, databases, geo search, cancellations, and what happens when each service fails.