JetStream Pull Consumer MaxAckPending and Flow Control
25.5K reputation · 11 Aug 2023, 18:43 UTC
NATS JetStream utilizes the MaxAckPending configuration to limit the number of unacknowledged messages a consumer can have outstanding. This mechanism is critical for preventing consumer saturation and managing resource allocation on the server.
When using Pull Consumers with AckExplicit, the client controls the request rate via batch sizes. However, there is a design uncertainty regarding the interaction between the server-side MaxAckPending limit and the client-side pull request volume when the consumer experiences processing delays.
- If the number of unacknowledged messages reaches the
MaxAckPendinglimit, the server stops delivering new messages regardless of subsequent pull requests. - The recovery behavior depends on whether the client continues to request batches while the limit is hit.
What is the precise behavior of the server when a Pull Consumer requests a batch that would exceed the MaxAckPending threshold? Does the server return a partial batch, an empty response, or a specific error indicating the limit has been reached?