Go Concurrency Techniques for Self-Healing Applications
summary
Built a liveness probe that compares Kafka’s latest produced offset to each consumer’s committed offset and fails when committed offsets stop advancing, running with the Sarama client on Kubernetes and coordinated by errgroup/WaitGroup. Early design uses channels and mutex-protected maps, later replaced by sync.Map and a consumer getOffsets method to handle rebalances. Resulting system auto-restarts stuck consumers, exposes context cancellation, and reduced PagerDuty pages by 50%. Key pieces: liveness probe comparing Kafka produced vs committed offsets, Sarama client on Kubernetes, sync.Map + errgroup for lifecycle and concurrency.
AI-written summary · about
chapters (12)
- 0:00Introduction to scaling
- 1:08Event-driven architecture
- 3:06Kubernetes health checks
- 4:44Designing the custom probe
- 7:28Go implementation details
- 8:30Concurrency with channels
- 10:47Synchronization and mutexes
- 12:18Context and lifecycle
- 14:22Wait groups and error groups
- 15:49Addressing rebalances
- 18:24Key lessons and conclusion
- 20:25Q&A session
