CodingNeed.
Mid · Concurrency

Design a Bounded Worker Pool

Design a worker pool with bounded concurrency, cancellation, error handling, and a clear channel ownership model.

Examples

Compare approaches

Baseline approach

Begin by explaining the core mechanism, stating assumptions, and walking through one concrete example.

Time: Depends on design · Space: Depends on design

// Sketch jobs, results, context cancellation, and worker ownership.
Strong answer

Start a fixed number of workers reading a bounded jobs channel. The producer closes jobs; a coordinator closes results after all workers exit. Select on cancellation when sending and receiving.

Time: Discuss operation costs · Space: Discuss retained state

// Sketch jobs, results, context cancellation, and worker ownership.

Common traps

  • Unbounded goroutines shift overload into memory pressure.
  • State assumptions and justify trade-offs rather than memorizing a single answer.
Practise in the workspace →

Essential cookies keep your account signed in. Optional analytics is not configured on this site. Your choice does not affect access to lessons.

Read the Privacy Policy. You can change this choice in the footer.