cachingredisdistributed-system

How is it ensured that a user is not reading stale(not yet synced) data from read only Redis slave?


I am learning about Redis replication and I understood following facts

1. By Default replicas are read only.
2. All writes happen to master
3. Master writes changes to internal buffer and then sends them slave for sync
4. Slave receives the buffered information and writes them to their memory

I have a doubt/curiosity here -

Let us assume master has a key:value as name:rishi. this key-value is also in-sync/replicated in slave.

Now user updates the key name with a new value name:coder, and master puts the data in internal buffer to make it sync with slave/s.

Then, before slaves are updated a read query comes to Redis for "name" key, is there a chance that stale data can be read out of salves?


Solution

  • Yes, there is a small time window where older data can be read from replica (fka slave) nodes.

    Reference: Redis Replication