Senior · Concurrency
Bounded workers and overload
How do you keep one million jobs from becoming one million goroutines?
Try explaining this aloud before opening the answer. State your assumptions and trace a boundary case.
Reveal a strong answer
Separate queue capacity from worker count. A bounded queue caps retained waiting work; a worker limit caps active work. Each job still needs a deadline and a memory budget.
Define overload behavior: block with cancellation, reject, shed lower-priority jobs or persist work for later. A semaphore acquired inside a newly launched goroutine still permits unbounded waiting goroutines.
Own shutdown: stop intake, cancel or drain accepted work, wait for workers, then close resources. A results queue must also be bounded and cannot prevent workers from exiting.
Common trap
A large channel buffer postpones overload while increasing latency and retained memory.
Try it
An endpoint accepts 10,000 jobs/second but capacity is 1,000. Which metric reveals the problem before a crash?
Worked solution
Queue age and length expose the mismatch; rejection count and end-to-end latency show the chosen policy. Add admission control at intake, then measure sustainable throughput under a fixed resource budget.
Change the constraint
What happens to fairness when a single tenant fills the shared queue?
How did you do?
Self-assessment, not a compiler pass or interview score. Explain the reasoning unaided before marking understood.
Not marked. Progress stays on this browser, separate from course completion.
Primary references
Checked 2026-10-20. Use documentation for your pinned runtime, driver and tool version.