A bounded queue gives a channel a fixed capacity. When the queue fills, producers wait for space instead of allowing messages to accumulate without limit. This applies back pressure, helping prevent a consumer from becoming overloaded while keeping maximum memory usage deterministic. section 10.4.4
Use a bounded queue when:
- The consumer must be protected from a surge of work. section 10.4.4
- Predictable maximum memory usage matters. section 10.4.4
- Producers can tolerate waiting when capacity is exhausted. section 10.4.4
Choosing queue behavior
A thread pool using a bounded queue can slow task producers when workers are busy, preventing the queue from growing indefinitely. An unbounded queue avoids that wait but can leave the consumer overloaded; asynchronous messages that cannot tolerate waiting may therefore require an unbounded queue. section 10.4.4


