Day 15: Database Sharding
Imagine your database is one massive, city-wide library. Finding a book is getting slow! 😩
Sharding is like building smaller, neighborhood library branches. 🏡
Each "branch" (or shard) holds a portion of the books (data), making everything faster and easier to manage.
How do you sort the books?
• Range-Based: Branch 1 gets Authors A-M, Branch 2 gets N-Z. (Simple, but one branch might get too busy!)
• Hash-Based: A magic formula sends books to branches evenly. (Great for distribution!)
• Directory-Based: A master catalog tells you exactly which branch every book is in. (Flexible, but adds a step.)
Why do it?
✅ Insane Scalability
✅ Faster Performance
✅ Better Availability
The Catch?
⚠️ Complex setup & maintenance
⚠️ Asking for books from two different branches at once is a pain (cross-shard queries).
Rule of Thumb: Shard when your single library is overflowing, not just because you can build new ones.
#SystemDesign #Database #Scalability #BigData #Sharding