Watch
The Weirdest Bug in Programming - Race Conditions
Animates two threads interleaving a read-modify-write step by step, showing how a check-then-act sequence produces a result no single ordering would.
Engineering Fundamentals for the Agent Era
Check-then-act races, such as checking stock and then decrementing it in two separate steps.
An unbounded fan-out of thousands of parallel requests that overwhelms a downstream service or trips its rate limits.
Mutable module-level state shared across requests, leaking one user's data into another user's response.
A deadlock from two code paths taking the same two locks in opposite order.
What goes wrong when many things happen at once, within one process or across many workers: races, deadlocks and overload.
An agent wrote a script that starts sending a welcome email to all 80,000 new users at once with no concurrency limit. The loop sets a module-level greeting variable just before each call to the send function, and the send function reads that variable only after it has awaited the mail connection. Find both defects and the symptom each one produces in production.
Watch
Animates two threads interleaving a read-modify-write step by step, showing how a check-then-act sequence produces a result no single ordering would.
Separates concurrency, which is structuring independent tasks, from parallelism, which is running them at the same time, and builds the idea around communicating through channels instead of shared state.
Explains queueing behavior under load and why unbounded queues hide overload until latency collapses, making the case for bounded queues and backpressure.
Its concurrency part covers race conditions, locks, condition variables, event-based concurrency and deadlock prevention through lock ordering, in short free chapters.
The rigorous treatment of mutual exclusion, lock implementations and concurrent data structures, for readers who want to know why a lock is correct.
Reference
Fred Hebert's explanation of why adding a queue in front of a slow consumer only delays the failure, and why you must bound it or push back on the producer.
Manual
Explains single-threaded event-loop concurrency, how one slow synchronous call stalls every request, and when to move work to real parallelism.