We are obtaining a very interesting graph in our Redis architecture.

- Green: master
- Blue: slave
Looks like the master Redis is executing 35% more commands than the slave Redis.
It is not always the same distance.
Here is part of the log of the active redis server:
[26911] 14 Feb 13:28:44 - DB 0: 2399 keys (417 volatile) in 16384 slots HT.
[26911] 14 Feb 13:28:44 - DB 1: 498 keys (498 volatile) in 1024 slots HT.
[26911] 14 Feb 13:28:44 - DB 2: 1 keys (0 volatile) in 4 slots HT.
[26911] 14 Feb 13:28:44 - 706 clients connected (1 slaves), 33794240 bytes in use
and during the same time on the salve:
[17748] 14 Feb 13:28:44 - DB 0: 2398 keys (417 volatile) in 16384 slots HT.
[17748] 14 Feb 13:28:44 - DB 1: 497 keys (497 volatile) in 1024 slots HT.
[17748] 14 Feb 13:28:44 - DB 2: 1 keys (0 volatile) in 4 slots HT.
[17748] 14 Feb 13:28:44 - 1 clients connected (0 slaves), 24839792 bytes in use
So they look like they are almost 1:1 synchronized.
We wonder which can be the cause of this gap. Also we are asking our selves if this means there are unnecessary commands sent to Redis that we can optimize.
Here’s a possible explanation:
total_commands_processedreports all commands, reads, writes and server related commands. Only write commands will be propagated to the slave(s).In a setup where you only write to the master, and read from the slave(s), you will have a higher
total_commands_processedon the slave(s) (all reads + all writes).If you write to and read from the master, and only keep the slave as a backup, or to persist to disk, the master will have a higher
total_commands_processed.In fact, it’s very improbable that the master and slave will have the same number of
total_commands_processed.