Redis Cluster
Redis cluster provide both sharding and replication.
It auto partition your dataset across multiple master nodes
Per shard single thread execution (ONLY IN CLUSTER)
For redis cluster, each shard is single thread execution. This is important to achieve more performance.
It splits keys across multiple separate Redis processes (shards), each running its own single thread:
| Setup | Parallelism |
|---|---|
| Single Redis instance | Zero — all keys, one thread |
| Redis Cluster (e.g., 6 shards) | 6 commands in parallel — but only if they hit different shards |
So XADD key1 and XADD key2 can run in parallel only if key1 and key2 hash to different shards in a cluster. On a single node, they're always sequential.
This is also why your hot-key sharding answer in the interview was important — if one popular user's key gets all the traffic, you're bottlenecked on one shard's single thread. Splitting rl:user123 into rl:user123:0, rl:user123:1, etc. spreads it across shards and across threads.
So redis cluster, all command for the same key will be single thread, all command for different key will be in different thread provided that they hit differnet shard:
- Same key → always same shard → always same single thread → sequential, always
- Different keys, same shard → same single thread → sequential
- Different keys, different shards → different processes, different threads → parallel