System Design
16. Performance EngineeringAnimated
Lock Contention
Threads waiting on the same lock.
The idea
Many threads fighting for a lock slow everything down.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- current message
- earlier
- failure or attack
Txn 1 locks row A.
- step:
- 1/6
- from:
- Txn 1
- to:
- Row A
1/6
Time runs downward. Solid arrows are requests, dashed arrows are replies.
Step by step
- 1Many threads request a lock
- 2One holds it
- 3Others wait
- 4Throughput drops
Where it is used
Concurrent systems.
Watch out for
Use finer locks, lock-free structures or fewer shared writes.