Course contentsShow
← Software Engineering
Lesson 1397 of 1,93341. Scalability and Distributed SystemsFree lesson

Partitioning Strategies: Range-Based

Using continuous key ranges to distribute data across partitions, with trade-offs around hotspots and range queries.

Partitioning Strategies: Range-Based

You'll learn how range-based partitioning distributes data across servers using continuous key ranges, and why it's powerful yet risky.

What Is Range-Based Partitioning?

Range-based partitioning splits data across multiple partitions by assigning each partition a continuous range of keys. Think of it like organizing a massive library: all books with titles A-F go to shelf 1, G-M to shelf 2, and N-Z to shelf 3.

For example, with user IDs:

  • Partition 1: IDs 1-1,000,000
  • Partition 2: IDs 1,000,001-2,000,000
  • Partition 3: IDs 2,000,001-3,000,000

You pick a partition key (like user ID, timestamp, or alphabetical name), define ranges, and route data accordingly.

Why Use Range-Based Partitioning?

Range queries become incredibly efficient. Need all users with IDs between 500,000 and 600,000? You only query Partition 1. Need all orders from January 2024? If partitioned by timestamp, that's likely a single partition hit.

This is unlike hash-based approaches where related data gets scattered randomly across all partitions.

The Major Trade-Off: Hotspots

The danger? Uneven data distribution creates hotspots. If you partition by timestamp and most activity happens "now," the newest partition gets hammered while older ones sit idle. If you partition alphabetically by last name and half your users are named "Smith," one partition drowns.

Popular key ranges get overloaded while others remain underutilized—defeating the purpose of partitioning.

Mitigation Strategies

Smart range selection helps: partition by composite keys (like country + user_id), pre-split known hot ranges, or monitor usage and rebalance boundaries dynamically.

Key Takeaway: Range-based partitioning enables efficient range queries by keeping related data together, but requires careful key selection to avoid hotspots where popular ranges overwhelm specific partitions.