Course contentsShow
← System Design
Lesson 250 of 1,9197. Database Scaling: ShardingFree lesson

Hybrid Sharding Strategies

Combine multiple sharding approaches (e.g., geo + hash) to balance competing requirements like locality and distribution.

Hybrid Sharding Strategies

What you'll learn: How to combine multiple sharding approaches to handle complex real-world requirements that a single strategy can't solve alone.

Why Hybrid Sharding?

In practice, your system often faces competing requirements. For example, you might need data locality for users in specific regions (geo-sharding), but also want even distribution to avoid hotspots (hash-sharding). A single sharding strategy rarely satisfies all constraints optimally.

Hybrid sharding means applying different sharding techniques together—either in layers or combined into a composite key—to balance multiple goals simultaneously.

Common Hybrid Patterns

Geo + Hash: First shard by geographic region to keep data close to users, then hash-shard within each region for even distribution. This gives you low latency and load balance.

Entity + Range: Shard by customer ID (entity-based) to keep all customer data together, then range-shard historical data by timestamp to archive old records efficiently.

Directory + Consistent Hashing: Use a directory to map logical shards, but employ consistent hashing within the directory to minimize data movement when adding shards.

Example Scenario

Imagine a global e-commerce platform. You need:

  • Users in Europe to hit European servers (geo requirement)
  • Even traffic distribution within Europe (hash requirement)
  • All orders for one customer queryable together (entity requirement)

Solution: Shard first by region (geo), then by hash(customer_id) within each region. Queries for one customer stay in one shard, European users get low latency, and no single server is overloaded.

The Trade-off

Hybrid strategies add complexity to your routing logic and require careful coordination when resharding. But for large, global systems, they're often the only practical way to meet all requirements.

Key Takeaway: Hybrid sharding combines multiple strategies (like geo + hash or entity + range) to satisfy competing requirements like locality, distribution, and query efficiency—at the cost of increased routing complexity.