Prev Next

Database / ValKey Interview questions

How does Valkey Cluster achieve horizontal scaling through hash slots?

Every key is mapped to one of 16384 fixed slots using CRC16(key) mod 16384, or the portion of the key inside curly braces when a hash tag like {user1000}.profile is used to force related keys into the same slot.

Each slot is owned by exactly one primary node at a time, and the cluster distributes ownership of the full slot range across all primaries so no single node has to hold the entire dataset.

flowchart LR K[Key] --> H["CRC16(key) mod 16384"] H --> S[Slot 0-16383] S --> N1[Primary Node A] S --> N2[Primary Node B] S --> N3[Primary Node C] N1 -.MOVED redirect.-> Client

Scaling out simply means assigning some existing slots to a newly added node and migrating their keys, spreading both storage and command load across more machines without any application code changes.

A key's cluster slot is computed as...
When a client contacts a node that doesn't own a requested key's slot, it receives...

More Related questions...

What is Valkey? What is the purpose of Valkey? What are the data types supported by Valkey? How do you install Valkey on a Linux server? Define Valkey persistence? What is RDB persistence in Valkey? What is AOF persistence in Valkey? Describe Valkey replication? List the eviction policies supported by Valkey? What is the purpose of Valkey Sentinel? What is Valkey Cluster? How do you apply a TTL to a key in Valkey? What is the purpose of the valkey.conf configuration file? How do you use the Valkey CLI to connect to a remote, password-protected server? Explain the basic architecture of a Valkey server? Why was Valkey created? Why do we use Valkey instead of Redis? What is the difference between Valkey and Redis? How does Valkey Cluster achieve horizontal scaling through hash slots? How does Valkey handle automatic failover in Sentinel mode? When should you choose Valkey Cluster over Sentinel? What is the difference between RDB and AOF persistence? How can you optimize memory usage in Valkey? How do you troubleshoot high latency in a Valkey deployment? Explain the lifecycle of a command from a Valkey client to execution and response? Explain the execution flow of primary-replica replication in Valkey? Explain the internal working of the Valkey single-threaded event loop? Why doesn't Valkey execute commands using multiple threads by default? What happens when a primary node fails in a Valkey Cluster? Which is better and why: Valkey Cluster or client-side sharding? How does Valkey implement publish/subscribe messaging? What is the difference between LPUSH and RPUSH? How do you use Valkey Streams for event processing? What are Valkey modules and how do you load one? How does Valkey handle expired key deletion internally? What is the difference between Valkey and Memcached? How do you secure a Valkey deployment in production? What is the role of ACLs in Valkey? How does Valkey handle memory fragmentation? What is the difference between WAIT and replica acknowledgment in Valkey? How do you perform a zero-downtime Valkey version upgrade? Explain the internal working of Valkey's hash slot mechanism in cluster mode? How do you troubleshoot a split-brain scenario with Valkey Sentinel? Explain the difference between Valkey Cluster mode and standalone mode? How does Valkey achieve high availability? What is the difference between synchronous and asynchronous replication in Valkey? How do you monitor Valkey performance in production? Explain the internal working of Valkey's LRU and LFU eviction algorithms? Why should you avoid running the KEYS command in production? How does Valkey's multi-threaded I/O model improve throughput over classic single-threading?
Show more question and Answers...


Comments & Discussions