Concurrency, Locking & Distributed Locks
Race conditions, optimistic vs pessimistic locking, atomic ops, Redis/etcd locks, fencing tokens and deadlocks — the bugs that only show up at 3 AM under load.
About 110 minutes · 15 exam questions · 9 interview questions · 2 code labs
What you will learn
- Race conditions: check-then-act and read-modify-write
- Concurrency inside one Node process: the event loop is not a mutex
- Optimistic locking: version columns and compare-and-set
- Pessimistic locking: SELECT ... FOR UPDATE, NOWAIT, SKIP LOCKED
- Atomic operations & CAS: let the storage enforce the invariant
- Duplicates: unique constraints and idempotency keys
- Distributed locks with Redis: SET NX PX and safe release
- Redlock, fencing tokens and consensus-backed leases (etcd/ZooKeeper)
- Producer-consumer, worker pools and SKIP LOCKED queues
- Deadlocks: detection, prevention and retry
- Scenario playbook: the seven concurrency incidents interviewers love
Previous: Idempotency, Distributed Transactions, 2PC & Sagas · Next: Data Systems Theory: System Models, Ordering, Encoding & Derived Data