Concurrency · 3 MIN READ

More goroutines are not more capacity

Bound active workers and queued work according to the resource that actually limits throughput.

Concurrency is how work overlaps. Capacity is how much useful work the system can sustain. A thousand waiting goroutines do not give Redis a thousand extra cores or increase a database connection budget. They do consume memory, queue time and cancellation bookkeeping.

01

Start with a budget

Suppose one downstream operation takes about 20 ms at the target load. Twenty concurrent operations can support roughly 1,000 operations per second in that simplified steady-state example. Real latency distributions, payload size and server limits change the result. Treat it as a sizing hypothesis, then measure tail latency and saturation.

02

Apply admission control before creating more work

A fixed worker count bounds active calls. A bounded jobs channel also bounds queued work. A context-aware producer stops waiting when the request is no longer useful. This fragment shows the admission point; workers, cancellation and channel ownership must all belong to the same enclosing operation.

go
jobs := make(chan Job, 32)
// Start a fixed number of workers elsewhere.
select {
case jobs <- job:
    // Accepted into the bounded queue.
case <-ctx.Done():
    return ctx.Err()
}
Read the code

Do not launch a new goroutine for every rejected or blocked enqueue: that merely moves an unbounded queue from the channel into goroutine stacks.

03

Pick a deliberate overload response

For request/response traffic, reject work that cannot meet its deadline or wait only within a bounded budget. For background work, use a durable queue if losing work is unacceptable. A worker pool limits concurrency, not requests per second; add rate limiting when the downstream contract is a rate. Track active calls, queue depth, queue age, errors and latency together.

TAKE THIS WITH YOU

Bound workers, waiting work and waiting time. Size those limits from downstream behavior, then verify under load.

Check your understanding

Which statement is correct about a bounded worker pool?

Go to the source

Progress stays in this browser. No account needed.