Dealing With Contention medium
How does using Thread-Local Storage eliminate contention?
- A It gives each thread its own private copy of the variable, meaning no sharing and no locking is required at all.
- B It uses a faster lock.
- C It stores data in the CPU cache.
- D It uses the disk.
Answer: A. It gives each thread its own private copy of the variable, meaning no sharing and no locking is required at all.
Ideal for things like Random Number Generators or User Contexts. No sharing = No race = Infinite scaling.
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: