Bird
Raised Fist0
Redisquery~20 mins

Client discovery through Sentinel in Redis - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Sentinel Client Discovery Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate
2:00remaining
Discovering the current master address using Sentinel
Given a Redis Sentinel setup monitoring a master named mymaster, which command returns the IP and port of the current master node?
Redis
SENTINEL get-master-addr-by-name mymaster
A["127.0.0.1"]
B["6379"]
C["mymaster", "127.0.0.1"]
D["127.0.0.1", "6379"]
Attempts:
2 left
💡 Hint
The command returns a two-element array with IP and port.
🧠 Conceptual
intermediate
1:30remaining
Understanding Sentinel's role in client discovery
What is the primary purpose of Redis Sentinel in client discovery?
ATo provide clients with the current master node address dynamically
BTo store all client connection information permanently
CTo act as a proxy between clients and Redis servers
DTo replace Redis servers during downtime
Attempts:
2 left
💡 Hint
Sentinel helps clients find the right master after failover.
📝 Syntax
advanced
2:00remaining
Correct syntax for querying Sentinel for master info
Which of the following commands correctly queries Sentinel to get detailed information about the master named mymaster?
ASENTINEL get-master-info mymaster
BSENTINEL master mymaster
CSENTINEL masters mymaster
DSENTINEL info mymaster
Attempts:
2 left
💡 Hint
The command is singular and uses the exact master name.
🔧 Debug
advanced
2:00remaining
Identifying error in Sentinel client discovery command
A client runs the command SENTINEL get-master-addr-by-name mymaster but receives an empty array []. What is the most likely cause?
AThe Sentinel instance is not monitoring any master named 'mymaster'
BThe Redis server is down
CThe client command syntax is incorrect
DThe Sentinel instance is overloaded with too many clients
Attempts:
2 left
💡 Hint
Check if the master name matches exactly what Sentinel monitors.
❓ optimization
expert
2:30remaining
Optimizing client discovery in a multi-Sentinel environment
In a Redis setup with multiple Sentinel instances, what is the best practice for a client to discover the current master efficiently and reliably?
AUse a static configuration with a fixed master address
BQuery only one Sentinel instance repeatedly until it responds
CQuery multiple Sentinel instances in parallel and use the first valid response
DQuery all Redis servers directly to find the master
Attempts:
2 left
💡 Hint
Multiple Sentinels provide redundancy; use it to avoid delays.

Practice

(1/5)
1. What is the main purpose of Redis Sentinel in client discovery?
easy
A. To automatically find the current Redis master server
B. To store data persistently on disk
C. To increase the speed of Redis commands
D. To backup Redis data to the cloud

Solution

  1. Step 1: Understand Sentinel's role and compare options

    Redis Sentinel monitors Redis servers and helps clients find the current master automatically. Only To automatically find the current Redis master server describes this discovery role; others describe unrelated features.
  2. Final Answer:

    To automatically find the current Redis master server -> Option A
  3. Quick Check:

    Sentinel = master discovery [OK]
Hint: Sentinel helps clients find the master automatically [OK]
Common Mistakes:
  • Confusing Sentinel with data storage
  • Thinking Sentinel speeds up commands
  • Assuming Sentinel handles backups
2. Which Redis command is used to get the current master address from Sentinel?
easy
A. SENTINEL get-master
B. SENTINEL get-master-addr-by-name
C. SENTINEL find-master
D. SENTINEL master-address

Solution

  1. Step 1: Recall the correct command syntax and verify options

    The official Redis command to get master address is SENTINEL get-master-addr-by-name. Only SENTINEL get-master-addr-by-name matches the exact command; others are incorrect or invalid.
  2. Final Answer:

    SENTINEL get-master-addr-by-name <master-name> -> Option B
  3. Quick Check:

    Command = SENTINEL get-master-addr-by-name [OK]
Hint: Remember full command: SENTINEL get-master-addr-by-name [OK]
Common Mistakes:
  • Using incomplete or wrong command names
  • Omitting 'get-master-addr-by-name'
  • Confusing with other Sentinel commands
3. Given the command SENTINEL get-master-addr-by-name mymaster returns ["192.168.1.10", "6379"], what does this output represent?
medium
A. The IP and port of the Sentinel server
B. The IP and port of a Redis slave server
C. The IP and port of the current Redis master named 'mymaster'
D. An error message indicating master not found

Solution

  1. Step 1: Understand the command output and match output meaning

    The command returns a two-element array: IP address and port of the master. Since the command queries the master by name, the output is the master's IP and port.
  2. Final Answer:

    The IP and port of the current Redis master named 'mymaster' -> Option C
  3. Quick Check:

    Output = master IP and port [OK]
Hint: Output array = [master IP, master port] [OK]
Common Mistakes:
  • Confusing master with slave address
  • Thinking output is Sentinel info
  • Assuming output is an error
4. You run SENTINEL get-master-addr-by-name mymaster but get an empty array []. What is the most likely cause?
medium
A. The Redis server is down
B. The client is connected to a Redis slave
C. The command syntax is incorrect
D. The Sentinel does not know about a master named 'mymaster'

Solution

  1. Step 1: Interpret empty array result and check possible reasons

    An empty array means Sentinel has no info on the requested master name. If the master name is unknown to Sentinel, it returns empty; syntax errors cause errors, not empty arrays.
  2. Final Answer:

    The Sentinel does not know about a master named 'mymaster' -> Option D
  3. Quick Check:

    Empty array = unknown master name [OK]
Hint: Empty array means unknown master name to Sentinel [OK]
Common Mistakes:
  • Assuming Redis server down causes empty array
  • Thinking syntax error returns empty array
  • Confusing slave connection with empty result
5. You want your application to automatically connect to the current Redis master even if failover happens. Which approach using Sentinel is best?
hard
A. Use SENTINEL get-master-addr-by-name to fetch master IP and port dynamically before connecting
B. Hardcode the master IP and port in your app configuration
C. Connect directly to a Redis slave and promote it manually if needed
D. Use Redis CLI to manually check master and update app config

Solution

  1. Step 1: Understand automatic master discovery and evaluate other options

    Using Sentinel's command to get the master address dynamically allows the app to adapt to failovers. Hardcoding IP/port or manual checks do not handle failover automatically; connecting to slaves is not reliable for writes.
  2. Final Answer:

    Use SENTINEL get-master-addr-by-name to fetch master IP and port dynamically before connecting -> Option A
  3. Quick Check:

    Dynamic master discovery = best practice [OK]
Hint: Always fetch master address dynamically via Sentinel [OK]
Common Mistakes:
  • Hardcoding master address ignoring failover
  • Connecting to slaves for writes
  • Manual updates instead of automatic discovery
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