Exponential Backoff vs Request Batching: Choosing the Right Strategy for Azure DevOps API Throttling
0 reputation · 22 Nov 2023, 18:53 UTC
0 reputation · 22 Nov 2023, 18:53 UTC
Minimize latency spikes that appear only when Azure DevOps REST APIs or pipeline agents receive concurrent requests.
Azure DevOps imposes rate limits that trigger throttling, but documentation only recommends exponential backoff for retried requests. It provides no clear guidance on when to switch to request batching, a technique that groups multiple calls into a single payload. Concurrent pipeline triggers also exhibit queue latency that is not evident in single‑threaded runs. The trade‑off between backoff and batching remains unresolved, and no official benchmark exists for different concurrency patterns.
Azure DevOps enforces a per‑user rate limit of about 120 requests per minute. Exceeding this triggers a 429 response with a Retry-After header. Batching endpoints (e.g., /git/repositories/{id}/items?api-version=6.0&$top=50) allow up to 50 items per request; exceeding that returns a 400. These figures are based on the latest public docs and community observations, but actual limits can vary by tenant and API version.
When you’re below the 5–10 request concurrency range, a simple exponential backoff (2‑second base, 2× multiplier, max 32 s) is usually sufficient: the added latency per request is small, and you avoid the risk of partial failures.
Once concurrency climbs past that threshold, the queue wait time dominates overall latency. Batching reduces the number of round‑trips and therefore the queue time, but you must handle larger payloads and potential partial failures. Idempotent operations and per‑item retry logic help mitigate the risk.
X-RateLimit-Remaining, Retry-After, and agent queue wait times for a representative set of requests at varying concurrency levels.X-RateLimit-Remaining < 20 or Retry-After > 5 seconds, switch to batching; otherwise, use backoff.To fine‑tune the threshold, we need to know the current Retry‑After values your tenant receives under typical load. Please share a sample of those headers (e.g., “Retry-After: 7”). This will help adjust the 5–10 request rule to your specific environment.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.