Virtual nodes place each physical server at many points on the ring. This helps distribute data more evenly and spreads a failed server's ranges across several surviving machines. The full visual walkthrough: hellointerview.com/twitter/c…
89
Consistent hashing puts servers and keys on a ring. A key belongs to the first server clockwise from its position. Adding a server takes over only the interval before that server; keys elsewhere keep their owners.
1
149
With hash(key) modulo N, N is the number of servers. Going from three servers to four changes the calculation for every key, and many keys get a different owner. Suddenly a routine capacity increase means widespread data movement.
1
157
Adding one server to your cache cluster can reshuffle most of its keys. Consistent hashing avoids that. Here's how.
1
22
1,335
Read the full breakdown:
hellointerview.com/twitter/t…
5
517
Cache event details and use Elasticsearch for discovery. Treat the seat map as a hint: availability can change between viewing a seat and trying to reserve it.
1
2
749
A virtual waiting room controls how many people reach checkout. More booking servers alone won’t fix millions of users competing for the same few seats.
1
2
1,308
Reserve seats for a few minutes while the user pays. An expiring Redis lock avoids holding a database transaction open through checkout. The final booking still needs a database concurrency check.
1
4
1,647
Search can tolerate stale data. Selling the same seat twice cannot. Give browsing and booking different consistency guarantees instead of forcing one policy on the whole system.
Starting from maximum depth, which is that pattern at its smallest: hellointerview.com/twitter/m…
106
Almost every tree question is then the same move: ask what each node needs from its children, and let recursion carry it up.
1
1
380
A binary tree is nodes with at most two children. Root at the top, leaves at the bottom, height is the longest path between them. That is the whole vocabulary.
1
25
1,158
When approximate is the right answer at scale, and when it quietly is not: youtube.com/watch?v=IgyU0iFI…
1
264
Count-Min Sketch handles frequency the same way. All three swap exactness for space, which is only a good deal when you know the error you are buying.
1
4
336
Bloom filters do the same trade for membership. Definitely not in the set, or probably in it, with no false negatives ever.
1
3
523
Counting unique visitors with a set costs memory proportional to the visitors. HyperLogLog answers the same question in kilobytes, and gets it slightly wrong on purpose.
The full pattern, including presigned uploads and CDN delivery: youtube.com/watch?v=RvaMHMxH…
2
335
So the metadata lives in your database and the bytes live in S3, and the interesting question is how the two stay in step when one write succeeds and the other does not.
1
4
588





