0
0
Redisquery~10 mins

Replication lag monitoring in Redis - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the command to check the replication offset on a Redis slave.

Redis
redis-cli info replication | grep [1]
Drag options to blanks, or click blank then click option'
Aconnected_slaves
Bmaster_repl_offset
Cslave_repl_offset
Drole
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'master_repl_offset' which shows master's offset, not slave's.
Using 'connected_slaves' which shows count, not offset.
2fill in blank
medium

Complete the command to check the replication lag in seconds using Redis latency info.

Redis
redis-cli latency latest | grep [1]
Drag options to blanks, or click blank then click option'
Areplication-delay
Bcommand-stats
Cslowlog
Dlatency
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'command-stats' which shows command statistics, not replication lag.
Using 'slowlog' which shows slow commands, unrelated to replication lag.
3fill in blank
hard

Fix the error in the command to monitor replication lag by comparing master and slave offsets.

Redis
master_offset=$(redis-cli info replication | grep [1] | cut -d':' -f2)
slave_offset=$(redis-cli info replication | grep slave_repl_offset | cut -d':' -f2)
lag=$((master_offset - slave_offset))
echo $lag
Drag options to blanks, or click blank then click option'
Amaster_repl_offset
Bslave_repl_offset
Cconnected_slaves
Drole
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'slave_repl_offset' for master offset causes incorrect lag calculation.
Using 'connected_slaves' which is unrelated to offsets.
4fill in blank
hard

Fill both blanks to create a Redis command that shows replication lag in bytes and seconds.

Redis
redis-cli info replication | grep [1]
redis-cli latency latest | grep [2]
Drag options to blanks, or click blank then click option'
Amaster_repl_offset
Breplication-delay
Cslave_repl_offset
Dcommand-stats
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'slave_repl_offset' instead of 'master_repl_offset' for byte lag.
Using 'command-stats' which is unrelated to replication lag.
5fill in blank
hard

Fill all three blanks to create a script snippet that calculates replication lag in bytes and prints a warning if lag exceeds threshold.

Redis
master_offset=$(redis-cli info replication | grep [1] | cut -d':' -f2)
slave_offset=$(redis-cli info replication | grep [2] | cut -d':' -f2)
lag=$((master_offset - slave_offset))
if [ $lag -gt [3] ]; then
  echo "Warning: Replication lag is high: $lag bytes"
fi
Drag options to blanks, or click blank then click option'
Amaster_repl_offset
Bslave_repl_offset
C1000
Dconnected_slaves
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up master and slave offset keys.
Using a non-numeric value for the threshold.