Interview › Databases & Caching
What is Redis Cluster, and how does sharding with hash slots work?
Databases & Caching · Advanced level
Answer
Redis Cluster shards the keyspace across 16,384 hash slots owned by primary nodes, with replicas for HA. Clients must be cluster-aware and multi-key operations need keys in the same slot.
Technical explanation
Redis Cluster splits keys across 16,384 hash slots.
Each primary owns slots and replicas provide HA for those slots.
Clients must handle MOVED/ASK redirects, and multi-key operations need same-slot keys.
Hands-on example
Hash-tag example:
cart:{user123}:items
cart:{user123}:total
CLUSTER KEYSLOT cart:{user123}:items
CLUSTER KEYSLOT cart:{user123}:totalBoth should map to the same slot.
Preparing for an interview?
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Databases & Caching interview questions
- What is the difference between Redis Sentinel and Redis Cluster?
- What is Redis replication, and how does a replica stay in sync?
- How does ElastiCache provide high availability and automatic failover?
- What is a cache hit ratio, and how do you improve it?
- What is the difference between Redis persistence options RDB and AOF?
- Why are some Redis commands (KEYS, FLUSHALL) dangerous in production?
- What is the difference between Redis as a cache and Redis as a primary datastore?
- How would you use Redis for rate limiting?