📖 Distributed Systems Core
Sharding Strategies
| Strategy |
Pros |
Cons |
| Hash-based |
Even distribution |
Range queries hard |
| Range-based |
Range queries easy |
Hotspots possible |
| Directory-based |
Flexible |
Lookup overhead |
Consistent Hashing
- Ring: Hash space as circle
- Virtual nodes: Multiple positions per physical node
- Addition/removal: Only K/N keys relocate
- Use cases: Cassandra, DynamoDB, memcached
Replication
Leader-Follower
- Writes: Go to leader
- Reads: Leader or followers (trade consistency for throughput)
- Failover: Promote follower, potential data loss
Leaderless
- Quorum: W + R > N for consistency
- Sloppy quorum: Availability over consistency
- Read repair + Anti-entropy: Eventual convergence
Consensus (Raft High-Level)