Phase
Concurrency Fundamentals
Goroutines, WaitGroups, races, mutexes, channels, worker pools, context, and graceful shutdown — the foundations every concurrent AI pipeline needs.
9 published · 0 upcoming
- Part 1Published
Part 1 - Why Concurrency Matters: Building the Wrong System First
Why Sequential AI Pipelines Stop Scaling
- Part 2Published
Part 2 - Goroutines and WaitGroups: Fixing One Bug, Finding Two More
We add goroutines to the pipeline and hit three problems in a row: a silently discarded goroutine, a loop-capture trap, and a real data race — ending with a working but unsafe concurrent system.
- Part 3Published
Part 3 - Race Conditions and Mutexes: Locking the Right Thing
Part 2 introduced goroutines and left a data race. Part 3 fixes it with sync.Mutex, then shows what happens when you lock in the wrong place. It also introduces sync.RWMutex for the case that appears in every real AI pipeline: many concurrent reads, rare writes.
- Part 4Published
Part 4 - Deadlocks: When Goroutines Wait Forever
Deadlocks are the silent failures of concurrent systems — no panic, no stack trace, just a process that stops making progress. We create three intentionally, read the runtime messages Go gives us, and build rules that prevent them.
- Part 5Published
Part 5 - Channels: Removing the Lock Entirely
We replace the mutex with a channel. No shared memory, no lock, same speed — and a look at why "share memory by communicating" is more than a slogan.
- Part 6Published
Part 6 - Buffered Channels and select
Unbuffered channels force synchronisation between sender and receiver. Buffered channels decouple them. And select — introduced here in the collector — lets you wait on multiple channels at once and proceed with whichever fires first.
- Part 7Published
Part 7 - Worker Pools: Decoupling Concurrency from Input Size
One goroutine per article does not scale to production traffic. We build a fixed-size worker pool and measure exactly how worker count trades off against throughput.
- Part 8Published
Part 8 - Context and Timeouts: Every Call Needs a Deadline
Every external call in a concurrent AI pipeline needs a deadline. We add context.WithTimeout to the worker pool and see, with real numbers, what happens when we do — and when we forget.
- Part 9Published
Part 9 - Cancellation and Graceful Shutdown: Stopping Safely
A pipeline that can not be stopped cleanly is not production-ready. We add OS signal handling, propagate cancellation through the worker pool, and build a ShutdownReport that accounts for every article — even under an abrupt stop.