Go for Infrastructure
Select fairness: operational verification
Explain how select chooses among ready channels by uniform pseudo-random selection, so source order gives no priority, and how a nested select can give one channel priority.
What you will be able to do
- Write a priority select that checks the high-priority channel first without blocking.
- Measure how often each case wins before deciding a priority rule is needed.
What is in the lesson
- A real situation where this goes wrong
- How it works, step by step
- A walkthrough with commands you can run
- How it fails in production, and how to tell
- Three quiz questions with explanations
Read this lessonFree. No account needed.
More in Go for Infrastructure
- GMP scheduler: operational verificationAdvanced · 5 min
Explain how GOMAXPROCS caps parallel Go code, how threads and processors relate to goroutines, and why too many threads stall under a CPU quota in a container.
- Channels: failure analysisAdvanced · 5 min
Explain how sends and receives block on channels, why a nil or unowned channel hangs, and how a select with a context case lets blocked goroutines exit.
- Context cancellation: failure analysisAdvanced · 4 min
Explain how a Go context cancels work, why a deadline does not stop a goroutine on its own, and how to find the calls that ignore it.
- WaitGroups: operational verificationAdvanced · 4 min
Explain how a WaitGroup counts outstanding goroutines in a fan-out job, why Add must run before Wait, and how a copied WaitGroup makes the job finish early.
- Mutex and RWMutex: failure analysisAdvanced · 4 min
Explain how Mutex and RWMutex protect shared data, why a waiting writer can deadlock a recursive read lock, and how to find lock waits in a goroutine dump.
- Atomic operations: operational verificationAdvanced · 4 min
Explain what sync/atomic guarantees for one value, why two atomic loads do not form a snapshot, and why 64-bit fields need alignment on 32-bit targets.