Scaling Reads hard
Your application shows high latency for DB queries, but the DB server CPU is low. You see high 'Connection Checkout Time' metrics in your app. What is the bottleneck?
- A The database disk is slow.
- B The network bandwidth is saturated.
- C The application Connection Pool is too small. Threads are waiting in a queue inside the application just to get a handle to the database.
- D The query is unoptimized.
Answer: C. The application Connection Pool is too small. Threads are waiting in a queue inside the application just to get a handle to the database.
This is a client-side bottleneck. The DB is bored, but the App restricts access to it. Increasing the pool size (or using an external multiplexer like PgBouncer) can release the pressure.
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?