Back-of-the-envelope EstimationSystem Design
Quick order-of-magnitude maths for QPS, storage and bandwidth that rules designs in or out before you draw boxes.
System Design Foundations →59 terms across algorithms, system design, distributed systems and AI — each linked to the course that teaches it.
Quick order-of-magnitude maths for QPS, storage and bandwidth that rules designs in or out before you draw boxes.
System Design Foundations →Depth-first search over choices that builds a candidate step by step and undoes each step after exploring it.
Recursion & Backtracking →Binary searching over possible answers (capacity, speed, days) using a monotone feasibility check instead of searching an array.
Binary Search →Many requests miss the cache at once (often after expiry) and overload the backing store; mitigated by locking, request coalescing or early refresh.
Real-time & Streaming →The application reads from cache first, loads from the database on a miss and populates the cache itself.
System Design Foundations →During a network partition a distributed system must choose between consistency and availability.
Replication & Consistency Models →Content Delivery Network: geographically distributed caches that serve static and cacheable content close to users.
System Design Foundations →Stops calling a failing dependency after an error threshold, failing fast and probing periodically until it recovers.
Fault Tolerance & Graceful Degradation →Mapping keys and nodes onto a ring so adding or removing a node only moves the keys adjacent to it.
Partitioning & Sharding →The maximum number of tokens a model can attend to in one request, including the prompt and its own output.
LLM Foundations →Conflict-free Replicated Data Type: a structure whose concurrent updates always merge deterministically without coordination.
Replication & Consistency Models →A queue that collects messages that repeatedly fail processing, so they can be inspected without blocking the main flow.
System Design Foundations →Single-source shortest paths on graphs with non-negative weights, expanding the closest unvisited node with a priority queue.
Graph →Every transaction records equal debits and credits across accounts, so balances always reconcile — the basis of payment systems.
Money & Ledgers →A dense vector representation of text (or images) where semantic similarity becomes geometric closeness.
Retrieval-Augmented Generation →If writes stop, all replicas eventually converge to the same value; reads in the meantime may be stale.
Replication & Consistency Models →A proof technique for greedy algorithms: show that swapping any optimal solution's choice for the greedy one never makes it worse.
Greedy →Pushing each new post into every follower's precomputed feed at write time; fast reads, expensive for accounts with huge followings.
Real-time Fan-out & Push →Two pointers moving at different speeds — used to detect cycles (Floyd's algorithm) and find the middle of a linked list.
Linked List →A monotonically increasing number issued with a lock or lease so storage can reject writes from a holder whose lease expired.
Locks & Coordination →A model emitting structured arguments for a declared tool, letting applications execute real actions from natural language.
Prompt Engineering & Structured Output →Encoding latitude/longitude into a string where shared prefixes mean nearby cells — a simple way to index and query locations.
Location & Mobility →Hierarchical Navigable Small World graph: the most common index for fast approximate nearest-neighbour vector search.
Storage Engines & Indexing →A client-generated unique key stored with the result of a request, so retries return the original result instead of repeating side effects.
Idempotency & Exactly-once →Linear-time maximum subarray sum: at each index either extend the previous subarray or start fresh.
Dynamic Programming →Stored attention keys and values for already-processed tokens, so generation doesn't recompute the whole prefix each step.
LLM Serving, Cost & Performance →A logical counter incremented on each event and merged on message receipt, giving an ordering consistent with causality.
Time, Clocks & Ordering →The strongest single-object consistency: every operation appears to take effect atomically at one point between its start and end.
Replication & Consistency Models →Using a model with a rubric to grade another model's outputs at scale; calibrated against human labels.
Evaluation & Guardrails →Log-Structured Merge tree: buffers writes in memory, flushes sorted files and compacts them — optimised for heavy write loads.
Storage Engines & Indexing →Model Context Protocol: an open standard for exposing tools, resources and prompts to AI applications through a common interface.
Agents & Tool Use →Caching the result of a recursive call by its arguments so overlapping subproblems are computed once — top-down dynamic programming.
Dynamic Programming →A stack kept in increasing or decreasing order; each pop resolves a 'next greater / smaller element' query in amortised O(1).
Stack & Queue →A multi-agent pattern where a lead agent decomposes a task, delegates sub-tasks to workers and synthesises their results.
Agentic AI Systems & Orchestration →Extends CAP: if Partitioned choose Availability or Consistency; Else choose Latency or Consistency.
Replication & Consistency Models →A running total where prefix[i] holds the sum of the first i elements, so any range sum is prefix[r] − prefix[l] in O(1).
Array →Untrusted input that tries to override an AI system's instructions — a core security concern for agents with tools.
AI System Design →A tree that recursively splits 2D space into four quadrants, adapting cell size to point density for proximity search.
Location & Mobility →Representing model weights in fewer bits (8-bit, 4-bit) to cut memory and cost with a small accuracy trade-off.
LLM Serving, Cost & Performance →A minimum number of replicas that must acknowledge a read or write; with W + R > N, reads see the latest write.
Replication & Consistency Models →An understandable consensus algorithm built from leader election, log replication and safety rules; used by etcd and Consul.
Consensus & Leader Election →Retrieval-Augmented Generation: retrieve relevant documents at query time and give them to the model so answers are grounded and citable.
Retrieval-Augmented Generation →A second, more accurate model (often a cross-encoder) that reorders the top retrieved passages before generation.
Retrieval-Augmented Generation →An agent pattern that interleaves reasoning steps with actions (tool calls) and observations until the task is done.
Agents & Tool Use →A long-running transaction split into local steps, each with a compensating action to undo it if a later step fails.
Distributed Transactions →A contiguous range that grows on the right and shrinks on the left while maintaining an invariant, giving linear-time subarray answers.
Sliding Window →A sampling parameter that sharpens (low) or flattens (high) the next-token distribution, trading determinism for diversity.
LLM Foundations →Latency from request to the first streamed token — the number users feel most in chat interfaces.
LLM Serving, Cost & Performance →The unit a language model reads and writes — a word piece produced by the tokenizer. Cost, latency and context limits are counted in tokens.
LLM Foundations →A rate limiter where tokens refill at a fixed rate and each request spends one, allowing short bursts up to the bucket size.
Rate Limiting & Admission Control →A linear ordering of a directed acyclic graph's nodes where every edge points forward; found with Kahn's BFS or DFS post-order.
Graph →Writing an outgoing event to an outbox table in the same transaction as the state change, then relaying it reliably to a broker.
Distributed Transactions →A max-heap for the lower half and a min-heap for the upper half of a stream, giving the running median in O(log n) per insert.
Heap →Two indices that move through a sequence — towards each other or in the same direction — to replace a nested loop with a single pass.
Array →A coordinator asks all participants to prepare, then to commit; atomic across nodes but blocking if the coordinator fails.
Distributed Transactions →A disjoint-set structure with near-constant find and union operations, using path compression and union by rank.
Graph →A per-node vector of counters that can tell whether two events are causally ordered or concurrent.
Time, Clocks & Ordering →In stream processing, a marker asserting that no events older than time T are expected, letting windows close and emit results.
Stream Processing & Aggregation →An append-only log written before data pages change, so the database can recover committed changes after a crash.
Storage Engines & Indexing →