Scaling Reads hard
Why is 'Statement-Based Replication' (sending SQL strings to replicas) risky for consistency compared to 'Row-Based Replication'?
- A SQL strings use more bandwidth.
- B Non-deterministic functions (like `NOW()`, `RAND()`, or UUID generation) will execute differently on the Replica than the Primary, causing data divergence.
- C It is slower.
- D It requires more CPU.
Answer: B. Non-deterministic functions (like `NOW()`, `RAND()`, or UUID generation) will execute differently on the Replica than the Primary, causing data divergence.
If you run `UPDATE users SET login_time = NOW()`, the Primary might write `12:00:01` and the Replica `12:00:02`. Row-based replication sends the *result* (`12:00:01`), ensuring identity.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- In a caching system, what is a 'Cache Miss'?
- Why is `SELECT * FROM Users` generally discouraged in high-performance applications compared to `SELECT name, email FROM Users`?
- You have users all over the world downloading large images from your server in New York. Users in Australia complain it is slow. What solves this?
- What is the main downside of reading from a Read Replica instead of the Primary database?
- You have maximized the RAM on your single database server, but it's still too slow. You decide to add 10 more servers to share the load. What is this called?
- You have 5 Read Replicas. How does the application know which one to ask for data?