Dealing With Contention medium
What happens when you have an Unbounded Queue in a high-contention system?
- A The system runs perfectly.
- B The memory fills up until the process OOM (Out Of Memory) crashes. It also increases latency significantly for items at the back of the queue.
- C The queue automatically resizes to disk.
- D The CPU usage drops.
Answer: B. The memory fills up until the process OOM (Out Of Memory) crashes. It also increases latency significantly for items at the back of the queue.
Always use bounded queues. It is better to reject work (Backpressure) than to crash the worker.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- Why is 'Exponential Backoff' preferred over constant intervals for retries?
- What is the primary purpose of a Mutex (Mutual Exclusion) lock?
- Why does adding more threads sometimes *decrease* performance?
- In a Saga, if a Compensating Transaction (Undo) fails repeatedly due to contention, what is the last resort?
- In a database, what happens if Transaction A locks a row and Transaction B tries to modify the same row?
- A database restart causes thousands of application servers to instantly try to reconnect. This crashes the DB again. This is called: