Subtracks & Tasks
Range Sharding
Implement Shard Controller
Build a shard controller that manages shard assignment: 1. Maintain configuration: which replica group owns which shards 2. Support operations: Join ...
Implement Consistent Hashing for Sharding
Use consistent hashing for shard assignment: 1. Place shards on a hash ring 2. Hash each key to a ring position 3. Find the next shard clockwise from...
Handle Configuration Changes
Handle shard configuration changes: 1. Replica groups poll controller for configuration updates 2. Detect when shard assignment changes 3. Start migr...
Implement Data Migration
Implement data migration between replica groups: 1. Source group: stop accepting writes for migrating shard 2. Create snapshot of shard data + client...
Build Complete Sharded Key-Value Store
Build a complete sharded KV store: 1. Client determines shard for key 2. Client routes to replica group owning shard 3. If wrong group, get new confi...
Consistent Hashing
Implement a Consistent Hash Ring
Consistent hashing places nodes and keys on a circular ring, minimizing key redistribution when nodes join or leave. Unlike modulo hashing (`hash(key)...
Add Virtual Nodes for Even Distribution
With few physical nodes, a consistent hash ring has uneven key distribution. Virtual nodes fix this by giving each physical node V positions on the ri...
Handle Node Addition with Minimal Key Migration
When a node joins, it takes over a portion of the key space from its clockwise neighbor. Only the keys that now fall in the new node's range need to m...
Handle Node Removal with Graceful and Crash Recovery
When a node leaves the ring (graceful shutdown or crash), its key range must be taken over by its successor. The two scenarios require different handl...
Implement Rendezvous Hashing (Highest Random Weight)
Rendezvous hashing (Highest Random Weight) is an alternative to consistent hashing. For each key, compute a score for every node, and the highest scor...
Cross-Shard Queries
Implement Scatter-Gather Query Execution
Scatter-gather is a fundamental distributed query execution pattern. The coordinator "scatters" a query to all shards, each shard processes its local ...
Implement Cross-Shard Aggregations
Distributed aggregations require computing partial aggregates on each shard, then merging partial results at the coordinator. Different aggregation fu...
Implement Cross-Shard JOINs
Cross-shard JOINs are expensive because they may require moving data across the network. The optimal strategy depends on how tables are partitioned. ...
Implement Secondary Indexes on Sharded Data
When data is sharded by a primary key (e.g., `user_id`), querying by a secondary key (e.g., `email`) requires a secondary index. There are two main st...
Implement Distributed ORDER BY with LIMIT
Implementing `ORDER BY score DESC LIMIT 10` in a distributed system requires each shard to return its local top results, then the coordinator merges t...
Interview Prep
Common interview questions for Distributed Systems / Backend Engineer roles that map directly to what you build in this track. Click any question to reveal the model answer.
Questions are representative of real interview patterns. Model answers are starting points — adapt them with your own experience and the specific context of the interview.
Common Mistakes
The top 5 mistakes builders make in this track — and exactly how to fix them. Click any mistake to see the root cause and the correct approach.
Comparison Mode
Side-by-side comparisons of the approaches, algorithms, and trade-offs you encounter in this track. Expand any comparison to see a detailed breakdown.
Concepts Covered
Prerequisites
It is recommended to complete the previous tracks before starting this one. Concepts build progressively throughout the curriculum.
Rabbit Holes
For when you want to go deeper. Curated papers, posts, and talks beyond what this track covers.
Consistent Hashing and Random Trees (Karger et al.)
The 1997 paper that introduced consistent hashing for distributed caching. The virtual node trick you implemented traces directly to Section 4 of this paper.
Spanner: Google's Globally Distributed Database
Corbett et al., 2012. The paper behind Google's globally distributed SQL database. How Spanner handles sharding and cross-shard transactions with TrueTime is the high-water mark of what distributed sharding can achieve.
Vitess: Scaling MySQL at YouTube
Vitess horizontally shards MySQL. The architecture documentation explains how their sharding layer handles resharding without downtime — a practical complement to the theoretical consistent hashing you implemented.
Citus: Distributed PostgreSQL
Citus shards PostgreSQL tables across worker nodes. Their distributed table concepts documentation is one of the clearest explanations of hash sharding versus range sharding in a production system.