Databases 6 min read

How to Split Hot Keys in Redis Cluster to Avoid Single-Shard Bottlenecks

Redis can become a bottleneck when a hot key concentrates traffic on a single shard; this article explains how to split such hot keys into multiple sub‑keys, distribute them across cluster nodes using CRC16 slot mapping, and implement the approach in high‑concurrency scenarios like coupon grabs or real‑time leaderboards.

Lobster Programming
Lobster Programming
Lobster Programming
How to Split Hot Keys in Redis Cluster to Avoid Single-Shard Bottlenecks

Redis is well known for its strong concurrency handling, but a single shard’s write capacity caps around 20,000 ops/sec and read capacity around 100,000 ops/sec. Even with a clustered deployment, a hot key that resides on one shard can overwhelm that shard under ultra‑high traffic.

To solve this, Redis key splitting (Redis分key) divides a hot key into several smaller keys and spreads them across different nodes in the Redis cluster.

For example, splitting a hot key into three sub‑keys allows each sub‑key to be mapped to a different shard, so the combined traffic is shared among three nodes instead of one.

2. Distribute Split Keys to Cluster Shards

Ensuring each sub‑key lands on a distinct shard requires understanding Redis cluster’s key‑to‑slot mapping. The process involves two steps: first, CRC16 computes a hash of the key, which is then modulo‑ed by 16384 to obtain a slot; second, the slot is assigned to a specific node.

Using Redis commands, you can query the cluster’s slot allocation and manually craft keys that map to desired slots. The manual steps are:

Write the first key (e.g., key_longxia ) and compute its CRC16 and slot to see which node it lands on (e.g., redis0).

Create a second key (e.g., key_longxia01 ); if it also maps to redis0, choose another key (e.g., key_biancheng ) that maps to a different node (e.g., redis1).

Similarly, craft a third key (e.g., key_long ) that maps to redis2.

The keys do not need to follow a strict pattern; adding random prefixes or suffixes is sufficient as long as each key maps to a different shard.

3. Working Principle of Split Keys

At runtime, the application selects a sub‑key based on the business ID modulo the number of split keys, then uses Redis’s two‑step mapping to locate the corresponding node and perform the operation.

Summary

Redis key splitting divides a hot key into multiple sub‑keys and distributes them across different cluster nodes (one sub‑key per node).

Manual calculation of CRC16 and slot mapping ensures each sub‑key lands on a distinct shard.

This technique is especially useful in ultra‑high‑concurrency scenarios such as coupon grabs, real‑time leaderboards, and other hot‑key workloads.

Redishigh concurrencyClusterDatabase ScalingKey Sharding
Lobster Programming
Written by

Lobster Programming

Sharing insights on technical analysis and exchange, making life better through technology.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.