Bird
Raised Fist0
Redisquery~20 mins

Adding and removing nodes in Redis - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Redis Cluster Node Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate
2:00remaining
What is the output of adding a new node to a Redis cluster?
You have a Redis cluster with 3 nodes. You run the command to add a new node to the cluster. What will the cluster nodes list show after adding the new node but before resharding?
Redis
redis-cli --cluster add-node 192.168.1.4:7004 192.168.1.1:7000
redis-cli --cluster nodes 192.168.1.1:7000
AThe new node appears in the cluster nodes list with no slots assigned.
BThe new node appears with all slots assigned to it.
CThe new node does not appear until resharding is done.
DThe cluster nodes list shows an error because slots are not balanced.
Attempts:
2 left
💡 Hint
Think about what happens immediately after adding a node before moving slots.
❓ query_result
intermediate
2:00remaining
What happens when you remove a node that holds slots without resharding?
In a Redis cluster, you remove a node that currently holds hash slots without migrating its slots first. What will be the state of the cluster?
Redis
redis-cli --cluster del-node 192.168.1.2:7002 <node-id>
AThe node is removed and slots are lost but cluster continues normally.
BThe cluster automatically migrates slots to other nodes.
CThe cluster enters an error state and refuses writes to affected slots.
DThe command fails because slots must be migrated before removal.
Attempts:
2 left
💡 Hint
Consider what happens to data when slots are suddenly missing.
📝 Syntax
advanced
2:00remaining
Which command correctly adds a node to a Redis cluster?
You want to add a new node at IP 10.0.0.5 port 7005 to an existing cluster with a node at 10.0.0.1 port 7000. Which command is syntactically correct?
Aredis-cli --cluster add-node 10.0.0.5:7005 10.0.0.1:7000
Bredis-cli --cluster add-node 10.0.0.1:7000 10.0.0.5:7005
Credis-cli --cluster add-node --node 10.0.0.5:7005 --cluster 10.0.0.1:7000
Dredis-cli --add-node 10.0.0.5:7005 10.0.0.1:7000
Attempts:
2 left
💡 Hint
The syntax is: redis-cli --cluster add-node
❓ optimization
advanced
2:00remaining
Best practice to minimize downtime when removing a Redis cluster node
You want to remove a node from a Redis cluster with minimal downtime. Which approach is best?
ARemove the node and rely on cluster auto-recovery to fix slots.
BMigrate slots from the node to be removed to other nodes, then remove the node.
CRemove the node immediately and then reshard slots manually.
DStop the entire cluster, remove the node, then restart the cluster.
Attempts:
2 left
💡 Hint
Think about how to keep data available during node removal.
🧠 Conceptual
expert
2:00remaining
Why is it important to reshard slots after adding a new node to a Redis cluster?
After adding a new node to a Redis cluster, why must you reshard slots to the new node?
ATo update the cluster configuration file automatically.
BBecause Redis requires manual slot assignment for security reasons.
CBecause the new node cannot join the cluster without slots.
DTo balance the data load and improve cluster performance.
Attempts:
2 left
💡 Hint
Think about what happens if slots are unevenly distributed.

Practice

(1/5)
1. What is the primary purpose of adding nodes to a Redis cluster?
easy
A. To increase the cluster's capacity and distribute data
B. To delete all data from the cluster
C. To backup the cluster data
D. To change the Redis version on all nodes

Solution

  1. Step 1: Understand what adding nodes means

    Adding nodes means increasing the number of servers in the cluster to share the data load.
  2. Step 2: Identify the effect of adding nodes

    More nodes mean more capacity and better data distribution across the cluster.
  3. Final Answer:

    To increase the cluster's capacity and distribute data -> Option A
  4. Quick Check:

    Adding nodes = More capacity and distribution [OK]
Hint: Adding nodes grows cluster capacity and data spread [OK]
Common Mistakes:
  • Thinking adding nodes deletes data
  • Confusing adding nodes with backup
  • Assuming adding nodes upgrades Redis version
2. Which of the following is the correct syntax to add a node to a Redis cluster using redis-cli?
easy
A. redis-cli --cluster add-node :<port> :<port>
B. redis-cli --cluster remove-node :<port>
C. redis-cli --cluster create-node :<port>
D. redis-cli --cluster add :<port>

Solution

  1. Step 1: Recall the command to add a node

    The correct command uses --cluster add-node followed by the new node and an existing node in the cluster.
  2. Step 2: Match the syntax

    redis-cli --cluster add-node :<port> :<port> matches the correct syntax: redis-cli --cluster add-node new-node existing-node.
  3. Final Answer:

    redis-cli --cluster add-node <new-node-ip>:<port> <existing-node-ip>:<port> -> Option A
  4. Quick Check:

    Correct add-node syntax = redis-cli --cluster add-node :<port> :<port> [OK]
Hint: Add node command uses --cluster add-node with new and existing nodes [OK]
Common Mistakes:
  • Using remove-node instead of add-node
  • Using create-node which does not exist
  • Omitting existing node IP in command
3. Given the command redis-cli --cluster del-node 192.168.1.5:7000 07c37dfeb2352e03a5a1e1f3a2f8b9a1f2e3d4c5, what will happen?
medium
A. A new node will be added at 192.168.1.5:7000
B. The node at 192.168.1.5:7000 will be removed from the cluster
C. The cluster will be created with the given node ID
D. The command will fail due to wrong syntax

Solution

  1. Step 1: Understand the del-node command

    The command redis-cli --cluster del-node removes a node from the cluster using its IP and node ID.
  2. Step 2: Analyze the given command

    The command specifies the node IP and the node ID, so it will remove that node from the cluster.
  3. Final Answer:

    The node at 192.168.1.5:7000 will be removed from the cluster -> Option B
  4. Quick Check:

    del-node removes specified node [OK]
Hint: del-node removes node by IP and node ID [OK]
Common Mistakes:
  • Confusing del-node with add-node
  • Thinking it adds a node
  • Assuming command syntax is incorrect
4. You run redis-cli --cluster add-node 192.168.1.10:7003 192.168.1.11:7000 but get an error. What is the most likely cause?
medium
A. The new node is already part of the cluster
B. The existing node IP is incorrect
C. The command should be --cluster del-node instead
D. Redis server is not running on the new node

Solution

  1. Step 1: Check prerequisites for adding a node

    The new node must be running Redis and reachable for the add-node command to succeed.
  2. Step 2: Identify common causes of add-node failure

    If Redis is not running on the new node, the command will fail because it cannot connect.
  3. Final Answer:

    Redis server is not running on the new node -> Option D
  4. Quick Check:

    New node must run Redis to add [OK]
Hint: New node must be running Redis before adding [OK]
Common Mistakes:
  • Assuming IP typo without checking server status
  • Confusing add-node with del-node command
  • Ignoring that Redis must run on new node
5. You want to remove a node from a Redis cluster but keep its data safe. Which sequence of commands should you use?
hard
A. Use redis-cli --cluster del-node then backup data manually
B. Directly stop the Redis server on the node and remove it
C. Use redis-cli --cluster reshard to move slots, then redis-cli --cluster del-node
D. Use redis-cli --cluster add-node to replace the node

Solution

  1. Step 1: Understand data safety when removing nodes

    Removing a node without moving its data causes data loss.
  2. Step 2: Use reshard to move data slots

    Resharding moves the data slots from the node to be removed to other nodes safely.
  3. Step 3: Remove the node after resharding

    After data is moved, del-node safely removes the node without data loss.
  4. Final Answer:

    Use redis-cli --cluster reshard to move slots, then redis-cli --cluster del-node -> Option C
  5. Quick Check:

    Reshard then del-node = safe removal [OK]
Hint: Reshard slots before removing node to keep data safe [OK]
Common Mistakes:
  • Removing node without moving data first
  • Stopping server directly causing data loss
  • Confusing add-node with removal process
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard