Interactive architecture diagrams for common distributed systems
A URL shortener must handle 10,000+ reads/sec with low latency. The key insight: reads vastly outnumber writes (100:1 ratio), so we optimize heavily for reads.
When a user posts, immediately write the tweet to all followers' feeds. Fast reads, slow writes. Celeb problem: 10M followers = 10M writes per tweet.
On read, merge feeds from all followed users. Fast writes, slow reads. Scales for celebrities but degrades for active readers following many accounts.
Traditional modulo hashing (key % N) requires remapping nearly all keys when a node is added/removed. Consistent hashing places both nodes and keys on a ring — only K/N keys need to move when a node changes (where K=keys, N=nodes).
Click "Lookup Key" to trace a key lookup through the ring.
In a distributed system, you can only guarantee 2 of 3 properties when a network partition occurs.
Returns error or waits if nodes disagree. No stale reads.
Always responds, may return stale data. Eventual consistency.
Works perfectly — until a partition. Then you must choose C or A.