Advanced Redis test (Advanced)
40 questions · 40 minutes · Free
Redis Cluster, Sentinel, Streams, Lua scripting and memory tuning.
What it covers
- Redis Cluster
- Redis Sentinel
- Redis Streams
- Lua scripting in Redis
- Redis memory optimisation
Interview format
- Questions: 40 questions — 24 multiple choice, 12 multi-answer, 4 predict-the-output
- Time: 40 minutes, timed from the first question
- Difficulty: Advanced
- Skill area: Data
- Price: Free
Earn a certificate
The Advanced Redis test is one of the 8 tests of the Backend Developer: Advanced learning path. Pass it and the other 7 tests at 70% or more and readyforhires issues you a verifiable certificate in your name, with its own code and verify link to share or add to LinkedIn.
Sample questions
5 sample questions from the Advanced Redis test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.
A Redis Cluster client sends a command to a key that is not located on the current node. What is the expected behavior of the client according to Redis Cluster's redirection mechanism?
- The client will receive an error and will not attempt to retry the command.
- The client will receive a MOVED response and update its slot map accordingly.
- The client will attempt to connect to all nodes in the cluster to find the correct one.
- The client will receive an ASK response and retry the command on the target node.
Answer: B. The client will receive a MOVED response and update its slot map accordingly.
In Redis Cluster, when a client sends a command to a key that is not located on the node it is connected to, the node responds with a MOVED error. This error contains the new node's IP and port, and the slot number. The client is expected to update its internal slot map and retry the command on the correct node. ASK responses are used during slot migration and are one-time redirects, but MOVED is used for permanent redirections.
What action does Redis Sentinel take during a master reconfiguration after a failover?
- Sentinel only notifies clients of the new master but does not reconfigure replicas.
- Sentinel automatically reconfigures clients to connect to the new master.
- Sentinel leaves the configuration unchanged and relies on clients to reconfigure themselves.
- Sentinel reconfigures replicas to follow the new master and rewrites its config file.
Answer: D. Sentinel reconfigures replicas to follow the new master and rewrites its config file.
When a failover occurs in Redis Sentinel, the Sentinel system reconfigures the replicas to follow the new master. It also rewrites the configuration file to ensure that the new master is recognized by the replicas. This is a key part of the failover process, ensuring that the system continues to function without manual intervention. Other options are incorrect because they either describe unrelated processes or incorrect behaviors of Redis Sentinel.
Which of the following statements is correct regarding Redis hash encoding memory efficiency?
- Using a single large hash with many entries and multiple small hashes has the same memory efficiency.
- Using a single large hash with many entries is more memory-efficient than using multiple small hashes.
- The memory efficiency of hash encoding is unaffected by the number of entries in a hash.
- Using multiple small hashes with fewer entries is more memory-efficient than using a single large hash.
Answer: B. Using a single large hash with many entries is more memory-efficient than using multiple small hashes.
Redis uses compact encodings like listpacks for small hashes, but when a hash exceeds certain thresholds (e.g., hash-max-listpack-entries), it switches to a more memory-intensive representation. Using a single large hash with many entries may exceed these thresholds and become less efficient compared to using multiple small hashes, which can stay within the compact encoding thresholds.
What error is returned by Redis Cluster when a multi-key command or Lua script is executed on keys that belong to different hash slots?
- KEYS error
- CROSSSLOT error
- ASK error
- MOVED error
Answer: B. CROSSSLOT error
In Redis Cluster, multi-key commands, transactions, and Lua scripts must operate on keys that belong to the same hash slot. If keys are spread across different slots, Redis will return a CROSSSLOT error. This is a safeguard to ensure data consistency and correctness in a distributed environment. Options B, C, and D are not errors related to cross-slot operations in Redis Cluster.
Which of the following statements correctly describes the role of Lua scripting in Redis memory optimization?
- Lua scripts increase memory usage by creating additional keys during execution.
- Lua scripts can only be used for read operations and cannot affect memory usage.
- Lua scripts can be used to perform atomic operations that reduce memory usage by ensuring that only necessary keys are accessed and modified.
- Lua scripts are not related to memory optimization and have no impact on memory usage.
Answer: C. Lua scripts can be used to perform atomic operations that reduce memory usage by ensuring that only necessary keys are accessed and modified.
Lua scripts allow for atomic operations that can reduce memory usage by ensuring that only the necessary keys are accessed and modified. This is crucial for memory optimization as it prevents unnecessary key creation and modification, which can lead to increased memory consumption. The other options do not accurately reflect the role of Lua scripting in memory optimization.
Frequently asked questions
- How many questions are in the Advanced Redis test?
- 40 questions (24 multiple choice, 12 multi-answer, 4 predict-the-output), with 40 minutes to answer them.
- What does the Advanced Redis test cover?
- Redis Cluster, Redis Sentinel, Redis Streams, Lua scripting in Redis, Redis memory optimisation.
- Is the Advanced Redis test free?
- Yes. It is free to take with a readyforhires account.
- What level is the Advanced Redis test?
- Advanced, in Data.