System Design Cheat Sheet
47 topics, one key fact each. For the full breakdown, follow any link.
Architectures
- URL ShortenerRead-heavy (100:1) → cache-aside with Redis on the hot path.
- WhatsApp / ChatPersistent WebSockets + sticky LB = real-time push.
- Instagram FeedFeed = precomputed Redis list of post IDs per user.
- YouTubeUpload → raw store → Kafka job → transcode ladder → CDN.
- NetflixFinite catalog → encode offline, pre-position on Open Connect at ISPs.
- Uber / Ride MatchingIndex drivers by spatial cell (H3/geohash) in memory for fast nearby queries.
- Dropbox / File SyncSplit files into chunks; upload only new blocks (delta sync).
- Search Engine / TypeaheadInverted index maps terms to postings lists; the heart of retrieval.
- Notification ServiceCentral API fans one notification out across channels and devices.
- Payment GatewayDouble-entry, append-only ledger is the strongly consistent source of truth.
- Rate LimiterRate limiter caps requests per key over a window, returning 429 when exceeded.
- News FeedFeed = ranked stream of followed accounts' posts; system is read-heavy.
- Food DeliveryThree-sided platform: customers, restaurants, couriers, plus payment.
Concepts
- RedisIn-memory KV store → microsecond reads.
- KafkaAppend-only log split into ordered partitions with offsets.
- RabbitMQPublish to exchange, route via bindings to queues, consume with acks.
- Load BalancerDistributes traffic across a pool behind one virtual endpoint.
- CDNEdge POPs cache content near users to cut latency.
- DNSMaps domain names to IPs via a hierarchical lookup.
- CachingStore hot data in a faster/closer layer to cut latency.
- ReplicationFull copies of data on multiple nodes for HA and read scaling.
- ShardingSharding = horizontal split of one dataset across independent nodes, each owning disjoint rows.
- PartitioningPartitioning splits a dataset: horizontal by rows, vertical by columns.
- Consistent HashingKeys and nodes share a hash ring; a key goes to the next node clockwise.
- Bloom FilterProbabilistic membership: answers 'definitely no' or 'possibly yes'.
- CAP TheoremCAP: pick 2 of Consistency, Availability, Partition tolerance.
- QuorumQuorum = minimum acks needed; N replicas, W write quorum, R read quorum.
- Leader ElectionLeader election picks one coordinator to serialize decisions; failover replaces it.
Patterns
- Cache-AsideApp checks cache → DB on miss → backfill cache.
- CQRSCommand side = writes/validation; query side = optimized reads.
- SagaSaga = sequence of local transactions + compensating actions.
- Circuit BreakerThree states: closed → open → half-open → closed.
- BulkheadPartition resources into isolated compartments.
- Pub/SubPublishers emit to topics; subscribers consume via a broker.
- Event SourcingStore immutable events, not just current state.
- Retry PatternRetry only transient, retryable failures.
- Outbox PatternWrite business change + outbox row in one local transaction.
- Write-Through CacheWrites go to cache and DB synchronously.
- Write-Back CacheWrite to cache, ack immediately, flush to DB async.
Tradeoffs
- SQL vs NoSQLSQL = fixed schema, ACID, joins, scale up.
- Redis vs MemcachedMemcached = simple, multithreaded, volatile string cache.
- Kafka vs RabbitMQKafka = replayable partitioned log; consumers pull by offset.
- REST vs GraphQLREST = fixed endpoints, server-defined shapes, easy HTTP caching.
- Polling vs WebSocketsPolling = repeated HTTP requests; short (timer) or long (held open).
- Replication vs ShardingReplication = full copies; scales reads and gives HA.
- Vertical vs Horizontal ScalingVertical = bigger machine; horizontal = more machines.
- Monolith vs MicroservicesMonolith = one deployable, shared DB, simple and fast to start.