Database Sharding
1 min readMar 27, 2024
What is Sharding?
- Database sharding is a technique for distributing a single across multiple servers.
- It is a key for horizontal scaling since the data, can be stored on multiple machines.
- It can also possibly improve the throughput of the database.
Advantages of Database Sharding
- Database sharding scalability : Sharding facilitate scale out, or horizontal scaling. By adding more machines to an existing stack, an organisation can permit more traffic, enable faster processing.
- Database sharding performance : Speed query response time. Sharding a massive table into multiple shard allows queries to pass over fewer rows and return result sets more rapidly.
- Reliability and Availability.
Drawbacks of Database Sharding
- Complexity : Increased complexity in designing sharding database.
- Hotspots. Even correctly implemented database sharding has a major impact on workflows as it requires that teams manage data across multiple shard locations without creating database hotspots and while ensuring even data distribution. Watch https://www.youtube.com/watch?v=ES2ov9s4ias&ab_channel=CockroachDB video to understand more about HotSpots.
Sharding Architectures
Key-based Sharding / Hash-based sharding : This is the most common way to split data across servers. Examples are consistent hashing, Ketama or Rendezvous.
Range Based Sharding
Directory Based Sharding
Resources