HTTP 429 and Retry-After: Schedule the Next Attempt Without a Retry Storm

For HTTP 429, honor the service's documented limit and any valid Retry-After header. Space out permitted retries and stop when the request's retry budget is exhausted. Retrying immediately can add load at the worst time.

Interpret the header before sleeping

Retry-After can be a delay in seconds or an HTTP date. In a synthetic response of Retry-After: 120, the server asks for a two-minute delay. For an absolute HTTP date, use a suitable parser and compare with the current UTC time. If a valid delay exceeds the time available to your task, defer it or report the rate limit.

Bound replay and concurrency

When the service permits retrying and provides no usable wait, follow its documented backoff guidance and add jitter where appropriate so clients do not all retry together. Cap the attempt count and total wait. For a non-idempotent operation, verify the API's replay behavior before sending it again.

Test with a stub and count actual attempts

Return one synthetic 429 and then a success from a local stub. Verify that a valid header defers the second request and that exhausted attempts surface an explicit error. Add invalid and absent header cases. In production diagnostics, compare attempt count and concurrency with the service's permitted usage rather than trying to avoid its controls.

Sources

댓글

이 블로그의 인기 게시물

소니 A6000 Wi-Fi 전송 (컴퓨터로 보내기)

SVN 서버 설치 및 웹 접속 설정-Ubuntu 14.04

VirtualBox(VM) 화면 크기 조절