Dealing With Contention easy
Why does adding more threads sometimes *decrease* performance?
- A It doesn't. More threads is always faster.
- B Due to Context Switching overhead and Lock Contention (threads spending more time waiting for locks than working).
- C Electricity cost.
- D The CPU gets confused.
Answer: B. Due to Context Switching overhead and Lock Contention (threads spending more time waiting for locks than working).
This is 'Thrashing'. If threads fight over a single mutex, 99% of CPU time is wasted on kernel scheduling logic, not application work.
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?
- 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:
- To save a system under extreme contention, you implement 'Load Shedding'. What is the most effective strategy?