Database Management Redis Subjective
Oct 05, 2025

How does Redis Clustering work for horizontal scaling?

Detailed Explanation
Redis Cluster provides horizontal scaling across multiple nodes: **Architecture:** • 16384 hash slots distributed across nodes • Each key mapped to a slot using CRC16 • Minimum 3 master nodes required • Each master can have replica nodes **Setup Example:** # Create cluster redis-cli --cluster create \ 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 \ 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 \ --cluster-replicas 1 # Check cluster status redis-cli -c -p 7000 cluster nodes redis-cli -c -p 7000 cluster info **Configuration (redis.conf):** cluster-enabled yes cluster-config-file nodes-6379.conf cluster-node-timeout 15000 cluster-announce-ip 192.168.1.100 **Client Usage:** from rediscluster import RedisCluster startup_nodes = [ {"host": "127.0.0.1", "port": "7000"}, {"host": "127.0.0.1", "port": "7001"}, {"host": "127.0.0.1", "port": "7002"} ] rc = RedisCluster(startup_nodes=startup_nodes, decode_responses=True) rc.set("key", "value") **Hash Tags (for multi-key operations):** SET {user:1000}:profile "data" SET {user:1000}:settings "config" # Both keys go to same slot
Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback