Bird
Raised Fist0
Redisquery~20 mins

Replication configuration in Redis - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Redis Replication Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate
2:00remaining
What is the role of the Redis instance after this configuration?
Given the Redis configuration line:
replicaof 192.168.1.100 6379
What role will this Redis instance have after restart?
AIt becomes a sentinel monitoring the master server.
BIt becomes a master and accepts writes independently.
CIt becomes a replica (slave) of the Redis server at 192.168.1.100:6379.
DIt disables replication and runs as a standalone server.
Attempts:
2 left
💡 Hint
The 'replicaof' directive sets the server role.
📝 Syntax
intermediate
2:00remaining
Identify the correct syntax to configure a Redis replica
Which of the following lines correctly configures a Redis server to replicate from master at 10.0.0.5 port 6380?
Areplicaof 10.0.0.5 6380
Bslaveof 10.0.0.5 6380
Creplica 10.0.0.5:6380
Dreplicaof=10.0.0.5 6380
Attempts:
2 left
💡 Hint
Use the modern directive for replication role.
🧠 Conceptual
advanced
2:00remaining
What happens if the master Redis server goes down in a replication setup?
In a Redis replication setup, if the master server stops responding, what is the expected behavior of the replica servers?
AReplicas continue serving read requests but stop syncing new data until master recovers.
BReplicas automatically become masters and accept writes immediately.
CReplicas shut down automatically to avoid stale data.
DReplicas delete their data and wait for manual intervention.
Attempts:
2 left
💡 Hint
Think about read availability and data consistency.
🔧 Debug
advanced
2:00remaining
Why does this Redis replica fail to sync with the master?
Given the Redis replica configuration:
replicaof 192.168.1.50 6379
and the master server is running and reachable, but the replica logs show:
Failed to connect to master: Connection refused
What is the most likely cause?
AThe replica server has no network connectivity.
BThe replica configuration syntax is incorrect.
CThe replica server is running on the same port as the master.
DThe master Redis server is not configured to accept connections from the replica's IP.
Attempts:
2 left
💡 Hint
Check master server's bind and firewall settings.
❓ optimization
expert
2:00remaining
How to optimize Redis replication for minimal data loss during failover?
Which configuration or practice helps minimize data loss when a Redis master fails and replicas take over?
AUse asynchronous replication without any acknowledgment settings.
BEnable 'min-slaves-to-write' and 'min-slaves-max-lag' to ensure writes only if enough replicas are synced.
CDisable replication to avoid delays in data syncing.
DConfigure replicas to accept writes immediately without failover coordination.
Attempts:
2 left
💡 Hint
Think about write safety and replication lag.

Practice

(1/5)
1. What is the primary purpose of Redis replication?
easy
A. To compress data stored on disk
B. To delete old data from the database
C. To copy data from a master server to replicas automatically
D. To encrypt data during transmission

Solution

  1. Step 1: Understand replication concept

    Replication means copying data from one server (master) to others (replicas) automatically.
  2. Step 2: Identify the main goal

    This copying helps keep data safe and allows multiple servers to serve read requests.
  3. Final Answer:

    To copy data from a master server to replicas automatically -> Option C
  4. Quick Check:

    Replication = Data copying [OK]
Hint: Replication means copying data from master to replicas [OK]
Common Mistakes:
  • Confusing replication with data deletion
  • Thinking replication encrypts data
  • Assuming replication compresses data
2. Which Redis command is used to configure a server as a replica of another?
easy
A. REPLICAOF <master_ip> <master_port>
B. CONNECT <master_ip> <master_port>
C. SYNC <master_ip> <master_port>
D. COPYFROM <master_ip> <master_port>

Solution

  1. Step 1: Recall Redis replication commands

    Redis uses the command REPLICAOF (formerly SLAVEOF) to set a server as a replica.
  2. Step 2: Check command correctness

    Only REPLICAOF accepts master IP and port to configure replication.
  3. Final Answer:

    REPLICAOF <master_ip> <master_port> -> Option A
  4. Quick Check:

    Replica config command = REPLICAOF [OK]
Hint: Use REPLICAOF to set replication target server [OK]
Common Mistakes:
  • Using CONNECT which is not a Redis replication command
  • Confusing SYNC with configuration command
  • Inventing COPYFROM which does not exist
3. Given this Redis config snippet:
replicaof 192.168.1.10 6379
replica-read-only yes

What is the effect of replica-read-only yes?
medium
A. The replica rejects write commands and only allows reads
B. The replica can accept write commands from clients
C. The replica disables replication from the master
D. The replica automatically becomes a master

Solution

  1. Step 1: Understand replica-read-only setting

    Setting replica-read-only to yes means the replica will not accept writes from clients.
  2. Step 2: Identify behavior of replica

    The replica only allows read commands and rejects any write commands to keep data consistent with master.
  3. Final Answer:

    The replica rejects write commands and only allows reads -> Option A
  4. Quick Check:

    replica-read-only yes = read-only replica [OK]
Hint: replica-read-only yes means no writes allowed on replica [OK]
Common Mistakes:
  • Thinking replica can write data with this setting
  • Assuming replication stops with this option
  • Believing replica becomes master automatically
4. You run replicaof 192.168.1.20 6379 on a Redis server but replication does not start. What is a likely cause?
medium
A. The command should be replicaof start instead
B. The master IP or port is incorrect or unreachable
C. The replica server has no data to replicate
D. Redis does not support replication

Solution

  1. Step 1: Check network and master details

    If replication does not start, often the master IP or port is wrong or the replica cannot reach the master.
  2. Step 2: Verify command correctness

    The command replicaof with IP and port is correct; no 'start' keyword is needed.
  3. Final Answer:

    The master IP or port is incorrect or unreachable -> Option B
  4. Quick Check:

    Replication fails if master unreachable [OK]
Hint: Check master IP and port if replication fails [OK]
Common Mistakes:
  • Using wrong command syntax like replicaof start
  • Assuming replication needs data on replica first
  • Thinking Redis does not support replication
5. You want to set up a Redis replica that can serve read requests but also allow some writes during maintenance. Which configuration is best?
hard
A. Use replicaof <master_ip> <master_port> and set replica-read-only yes
B. Set the replica as master with no replication
C. Do not use replication; instead manually copy data
D. Use replicaof <master_ip> <master_port> and set replica-read-only no

Solution

  1. Step 1: Understand replica-read-only option

    Setting replica-read-only to no allows writes on the replica, useful during maintenance.
  2. Step 2: Combine with replication setup

    Using replicaof configures replication; setting replica-read-only no allows writes while still replicating.
  3. Final Answer:

    Use replicaof <master_ip> <master_port> and set replica-read-only no -> Option D
  4. Quick Check:

    replica-read-only no allows writes on replica [OK]
Hint: Set replica-read-only no to allow writes on replica [OK]
Common Mistakes:
  • Assuming replica-read-only yes allows writes
  • Thinking manual copy replaces replication
  • Confusing replica with master roles
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