Skip to content

Interview Guide

These patterns show up constantly in system design and coding interviews. This page maps them to the questions you'll actually get asked.

How to Use This Page

  1. Find the interview topic you're preparing for
  2. Read the pattern pages linked in each section (understand the mechanism, not just the name)
  3. Run the interactive visualizations — interviewers love candidates who can draw and explain
  4. Try the exercises — they're structured like coding interview problems

System Design Interviews

"Design a Rate Limiter"

This is the single most common system design question. You need:

ConceptPatternWhat to Say
Token bucket algorithmRate Limiter"I'd use a token bucket — it handles bursts up to capacity while maintaining a steady refill rate"
Distributed rate limitingConsistent Hashing"For multi-node, I'd hash client IPs to specific rate limiter instances to avoid cross-node coordination"
Sliding window fallbackRing Buffer"A ring buffer can track request timestamps in the sliding window variant"

"Design a Cache"

ConceptPatternWhat to Say
Eviction policyLRU Cache"LRU with a doubly-linked list + hash map gives O(1) get/put/evict"
Cache stampede preventionSemaphore"Use a semaphore so only one request computes the value, others wait"
Distributed cache routingConsistent Hashing"Consistent hashing lets me add/remove cache nodes without full redistribution"
Negative cacheBloom Filter"A Bloom filter in front avoids cache lookups for keys that definitely don't exist"

"Design a Key-Value Store"

ConceptPatternWhat to Say
Write pathLSM Tree"Write to WAL, then memtable. When memtable is full, flush to sorted SSTable on disk"
Read optimizationBloom Filter"Each SSTable has a Bloom filter — skip files that definitely don't contain the key"
Crash recoveryWAL + Checkpointing"WAL ensures durability. Periodic checkpoints bound recovery time"
CompactionMerge Iterator"K-way merge of sorted SSTables using a min-heap"
DeletionTombstone"Can't remove from immutable SSTables — write a tombstone marker, compact later"

"Design a Distributed Database"

ConceptPatternWhat to Say
ReplicationWAL + State Machine"Raft: replicate WAL entries, apply to state machine in order"
ConsistencyLogical Clock"Lamport timestamps for total order, vector clocks for causal consistency"
PartitioningConsistent Hashing"Consistent hashing with virtual nodes for even distribution"
Anti-entropyMerkle Tree"Compare Merkle roots between replicas to find divergence in O(log n)"
Concurrent readsMVCC"Each transaction sees a consistent snapshot — readers never block writers"
Conflict resolutionTombstone + Logical Clock"Last-write-wins using vector clock comparison, tombstones for deletes"

"Design a Task Scheduler"

ConceptPatternWhat to Say
Priority queueMin Heap"Min-heap by deadline/priority — O(1) peek, O(log n) insert"
Fair schedulingWork Stealing"Idle workers steal from busy queues — Go runtime does exactly this"
Time slicingCooperative Scheduling"Each task yields after a time slice — React Scheduler does this to stay under 16ms"
Concurrency limitSemaphore"Semaphore with N permits limits concurrent task execution"
Task dependencyDependency Graph"DAG of tasks, execute in topological order"

"Design a Message Queue"

ConceptPatternWhat to Say
Producer bufferingRing Buffer"Fixed-size ring buffer for zero-allocation enqueue/dequeue"
Consumer flow controlBackpressure"If consumer is slow, signal producer to slow down — don't drop messages"
Ordered deliveryLogical Clock"Lamport timestamps ensure causal ordering across partitions"
Batched writesBatch Processing"Accumulate messages, fsync as a batch — Kafka does this for throughput"
DurabilityWAL"Append-only log on disk — replay for recovery"

"Design an API Gateway"

ConceptPatternWhat to Say
Rate limitingRate Limiter"Token bucket per client, per endpoint"
Circuit breakingCircuit Breaker"If backend error rate exceeds threshold, open circuit and fail fast"
Retry policyRetry with Backoff"Exponential backoff with jitter to avoid thundering herd"
Request pipelineMiddleware Chain"Auth → rate limit → transform → route → response — composable handlers"
Service discoveryRegistry"Services self-register, gateway looks up by name"

Coding Interviews

Data Structure Design

QuestionCore PatternKey Insight
"Implement an LRU cache"LRU CacheHash map + doubly-linked list, O(1) everything
"Design a trie with insert/search/startsWith"TrieRecursive children map, isEnd flag
"Implement a min-heap"Min HeapArray-based, siftUp on insert, siftDown on extract
"Design a skip list"Skip ListRandomized levels, search by descending levels
"Implement a Bloom filter"Bloom Filterk hash functions, bit array, no false negatives
"Design a thread-safe object pool"Object PoolAcquire/release with mutex or CAS

Algorithm Problems

QuestionCore PatternKey Insight
"Merge K sorted lists"Merge IteratorMin-heap of k heads, extract-min and advance
"Find the median in a stream"Min HeapTwo heaps: max-heap for lower half, min-heap for upper
"Implement an iterator that flattens nested lists"IteratorStack-based lazy traversal
"Detect cycle in linked list"Reference CountingFloyd's two-pointer is the standard solve — but cycles break ref counting, understanding why sets you apart
"Serialize/deserialize a tree"VisitorPre-order visit for serialize, recursive rebuild for deserialize
"Compute minimum edit distance"Diff / PatchDynamic programming on two sequences

Concurrency Problems

QuestionCore PatternKey Insight
"Implement a semaphore"SemaphoreCounter + mutex + condition variable
"Design a thread pool"Work StealingPer-thread deque, steal from tail
"Implement a read-write lock"SemaphoreCounting semaphore for shared readers, mutex for exclusive writer
"Producer-consumer problem"Ring Buffer + BackpressureBounded buffer with wait/signal
"Dining philosophers"SemaphoreResource ordering prevents deadlock

What Interviewers Actually Look For

It's not about memorizing patterns. Here's what distinguishes strong candidates:

1. Tradeoff Awareness

Don't just say "I'd use a Bloom filter." Say:

"A Bloom filter gives us O(k) lookups in O(m) bits of space, with tunable false positive rate. The tradeoff is we can't delete — for that we'd need a counting Bloom filter, which uses 4x the space."

Every pattern in this book has a When NOT to Use section — read those.

2. Production Context

Don't say "I'd use a queue." Say:

"I'd use a ring buffer like LMAX Disruptor — fixed size, no allocation, and the producer/consumer can be on different cores without cache-line contention because they access different indices."

The Production Proof section of each pattern gives you these references.

3. Composition

Real systems combine patterns. When designing a KV store, don't just say "LSM tree." Walk through the full stack:

"Writes go to a WAL for durability, then a memtable (sorted in-memory). When full, flush to an SSTable. Each SSTable has a Bloom filter for read optimization. Compaction uses a merge iterator to combine SSTables. Deletes use tombstones."

The Cheat Sheet has a Pattern Combos section for this.

4. Drawing

If you can sketch a pattern's mechanism on a whiteboard, you understand it. If you can't, you've only memorized the name. Every pattern's interactive visualization teaches you what to draw.

Study Plan

1 Week Sprint

DayFocusPatterns
1Caching & LookupLRU Cache, Bloom Filter, Trie
2Storage EngineWAL, LSM Tree, B+ Tree, Checkpointing
3ReliabilityCircuit Breaker, Rate Limiter, Retry with Backoff
4ConcurrencySemaphore, MVCC, Work Stealing
5DistributedConsistent Hashing, Logical Clock, Merkle Tree
6Memory & RuntimeObject Pool, Arena, Reference Counting, Copy-on-Write
7ReviewRun all exercises, practice drawing mechanisms

Weekend Crash Course

Focus on the 10 patterns that cover 80% of system design interviews:

  1. LRU Cache — every cache question
  2. Rate Limiter — dedicated interview question + used in API gateway
  3. Consistent Hashing — every distributed question
  4. WAL — every storage/database question
  5. LSM Tree — KV store design
  6. Bloom Filter — read optimization, set membership
  7. Circuit Breaker — API gateway, microservices
  8. MVCC — database concurrency
  9. Min Heap — scheduler, merge-k, median
  10. Merkle Tree — data integrity, anti-entropy

Released under the MIT License.