In this article
Classify the actual resource boundary before retrying; an RPC code is evidence, not a complete retry policy.
An inference client treats every unsuccessful RPC as temporary unavailability and retries it. A resource-exhausted response can instead describe a persistent quota, a message-size limit or another capacity boundary that the same request will hit again. Preserve the RPC code and diagnostic context before deciding whether waiting can change the outcome.
Keep the original code intact
The gRPC status model distinguishes resource exhaustion from unavailability and other failures. A gateway that maps all of them to one generic exception removes information the application needs. Retain the machine-readable code, sanitized details and safe correlation metadata. Do not derive the class solely from the description’s English wording. Library-generated and application-generated failures can share some codes, so the code should lead the investigation rather than end it.
Identify the exhausted resource
Check whether the response refers to request size, account policy, concurrent admission, memory or a service-specific budget. The code alone does not name the resource. Compare where the request became visible: client, gateway and application. If rejection happened before model admission, tuning the model’s scheduling algorithm may be irrelevant. If the engine admitted it and then exhausted memory, repeated attempts with identical work can make pressure worse.
Distinguish transient pressure from a fixed limit
A short queue surge can recover with a bounded delay and reduced offered load. A request that exceeds a documented message limit will not become acceptable merely because the client sleeps. A quota may reset under its own policy or require a different application decision. Avoid inventing a reset time or a universal backoff rule from the RPC code. Use the service’s documented metadata and policy, while keeping the caller’s deadline active.
Test the retry classifier
Create separate synthetic failures for temporary unavailability, an oversized message and an application-defined capacity rejection. Verify that the wrapper preserves their distinct evidence and chooses the intended bounded behavior. Inspect built-in retry configuration as well as the outer application loop. A library policy and a wrapper can independently replay work, multiplying attempts even when each appears bounded on its own. Keep logical request and attempt counts separate.
Explain what the client changed
The useful resolution may reduce request size, limit concurrency, wait under documented guidance or stop with a clear quota error. Preserve the reason and any partial-result limitation. Acceptance means the client does not blindly retry a permanent boundary, does not discard useful status and does not create unbounded pending work during transient pressure. It does not mean resource-exhausted calls are always permanent or unavailable calls are always safe to retry. Retry safety also depends on whether the generation may already have executed and on the API’s duplicate-handling contract.
Primary references
gRPC Status Codes. Defines ResourceExhausted, Unavailable and library versus application statuses.
gRPC Retry. Defines bounded retry policy and retryable-code selection.
gRPC Deadlines. Defines the deadline that constrains waiting and subsequent attempts.
Related reading: Provider overload: Retry-After as part of the contract; HTTP body limits and token limits: separate inference API checks.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.