Read Replica Pattern

Pasted image 20230902124037.png

Problem: replication lag

Happens when Alice placed an order and immediately read the order history. In this case, the replica could have a slight lag which will not return the latest result.

In this case there are a few solutions:

  1. For latency sensitive read, delegate to master DB
  2. For READ that do immedately after a WRITE action, query the master DB
  3. If query data is outdated, we serve from the master DB first and then update the read replica after