Suggest an editImprove this articleRefine the answer for “What sharding strategies exist?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)The main **sharding strategies** determine *what principle* data gets distributed between servers (shards) by: `hash sharding` (by a hash of the key - even distribution), `range sharding` (by a range of key values), geographic sharding (by region or another attribute), and `composite sharding` (a combination of several strategies). **Key point:** hash sharding gives even balance but makes aggregating across all shards harder; range sharding is simple but can produce uneven load; geographic sharding reduces latency but shards can vary a lot in size; hybrid sharding is universal but harder to manage.Shown above the full answer for quick recall.Answer (EN)ImageThe main **sharding strategies** determine *what principle* data gets distributed between servers (shards) by. This affects load balance, query simplicity, and scalability. ### 1. Hash sharding - Each record's hash is computed on a specific key (e.g. `user_id`), and the hash result determines which shard it lands in. - Provides **even data distribution**. - Downside: aggregate queries that need data from every shard become harder (e.g. aggregates). **Example:** `shard_id = hash(user_id) % N`, where *N* is the number of shards. ### 2. Range sharding - Data is split by ranges of key values (e.g. `user_id` from 1 to 1,000,000 is one shard, the next range is another). - Simple to implement, convenient for ordered data. - Downside: possible **uneven load** if some ranges are more active than others. ### 3. Geographic (or attribute-based) sharding - Data is split by an attribute tied to region, country, company branch, and so on. - Convenient when users are physically spread across regions, it reduces latency and improves local availability. - Downside: shards can vary a lot in size. ### 4. Composite (hybrid) sharding - Combines several strategies, e.g. first by region, then within each region by hash. - A flexible, scalable option for large systems. **Summary:** - **Hash sharding**, even, but harder to aggregate. - **Range sharding**, simple, but can produce uneven load. - **Geographic sharding**, reduces latency, but requires balancing the data. - **Hybrid sharding**, universal, but harder to manage.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.