Back to results for “Set”
Redis › Cluster Sharding & Hash Slots

What is sharding in a Redis Cluster, and why is it necessary for very large datasets?

Beginner

Answer

Sharding splits your data across multiple Redis nodes instead of storing everything on a single server, letting you scale beyond the memory and processing limits of one machine by distributing both the data and the workload of serving requests across several nodes working together.
-- A Redis Cluster automatically distributes keys
-- across multiple nodes based on hash slots
redis-cli -c -h node1 set user:123 'John'
Real-world example A large social media platform shards its user session data across many Redis nodes, since a single server could never hold enough memory to store session data for millions of active users at once.

Common follow-ups: How does Redis Cluster decide which node a specific key belongs to?;What happens if you need to add more nodes to a cluster later?