Sharding strategies: directory-based, range-based, and hash-based

What's this blog post about?

Sharding strategies can be categorized into three types: directory-based, range-based, and hash-based. Directory-based sharding involves mapping data to shards using a lookup table, which is useful for specific criteria but may result in uneven data distribution and an extra query step. Range-based sharding splits up the shard mapping based on a range of values, which can lead to overloaded shards but allows for easy resharding operations. Hash-based sharding distributes data evenly across shards using a hash function, minimizing human guesswork and offering easier resharding options. PlanetScale typically recommends hash-based sharding as the default option due to its simplicity and effectiveness in maintaining an even distribution of data.


Date published
July 8, 2024

Holly Guevara

Word count

Hacker News points
None found.


By Matt Makai. 2021-2024.