Scaling Reads medium
Your database is being hammered by queries for `User_ID: 999`, which does not exist. The database repeatedly scans the index and returns 'Null'. How do you protect the DB?
- A Block the user.
- B Implement 'Negative Caching': Cache the 'Null' result (e.g., `Key_999 = 'Not Found'`) with a short TTL.
- C Create a user with ID 999.
- D Disable the index.
Answer: B. Implement 'Negative Caching': Cache the 'Null' result (e.g., `Key_999 = 'Not Found'`) with a short TTL.
This prevents 'Cache Penetration'. By caching the *absence* of data, subsequent requests stop at the cache layer.
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?