PHASE 01 · MODULE 03
Concurrency and async runtimes.
Async does not make work faster. It lets one thread wait on thousands of things.
The real design questions are what limits concurrency and what happens when producers outrun consumers. Little's Law sizes the system: at 20 agent runs per second and 30 seconds per run, you hold 600 runs open. That one multiplication sizes connection pools, memory and rate limits.
Start lesson 1Basics
- Blocking and non-blocking I/O
- Threads and mutexes
- Races and deadlock
- Promises and microtasks
- Event-loop phases
Depth
- select, poll, epoll and kqueue
- Edge and level triggering
- Readiness versus completion
- libuv internals and worker threads
- SharedArrayBuffer and Atomics
- Go's M:N scheduler and Tokio work stealing
- AbortController and backpressure
- Structured concurrency and Amdahl's Law
Current
- io_uring
- Why io_uring is often switched off in production
Lessons
- 01Threads, races and deadlockTwo threads touching the same memory can interleave in ways that lose updates. Learn why
count++is three steps, how a mutex fixes it, and how two mutexes can freeze a program. - 02The event loop, tasks and microtasksJavaScript runs one piece of code at a time and picks the next piece from queues. Learn the order: synchronous code, then every microtask, then the next task.
- 03Blocking the loop and the thread poolOne slow synchronous call freezes every user on the process. Learn to spot event-loop blockers and the hidden four-thread pool behind fs, DNS and zlib.
- 04Readiness, completion and io_uringHow one thread waits on 10,000 sockets. Learn thread-per-connection, epoll's readiness model and io_uring's completion model, and why io_uring is often disabled.
- 05Little's Law and backpressureOne multiplication tells you how much the system holds open. Learn to size pools and queues with it, and what happens when producers outrun consumers.
- 06Cancellation, bounded parallelism and structured concurrencyStart work so that it can always be stopped and never outlives its owner. Then see how Go and Tokio schedule millions of tasks, and what Amdahl's Law says about speedups.
Module lab
- Build a TCP echo server three ways: one thread per connection, epoll, and io_uring.
- Hold 10,000 idle connections and compare memory.
- Write a bounded-concurrency queue for tool calls, with cancellation and a full-queue policy.
Interview questions
Why can one JSON.parse hurt every user?
Show the single-threaded event loop: nothing else runs until it returns.
What is the difference between readiness and completion I/O?
epoll says you can act now; io_uring says it is done.
What happens when you ignore res.write() returning false?
Buffers grow until memory runs out.
Read
- The libuv design overview
- Node.js guide: the event loop, timers and process.nextTick
- Efficient IO with io_uring, Jens Axboe
- Notes on structured concurrency, Nathaniel Smith