Risorse · 77
Quote e limiti delle API
I limiti condizionano capacità, ritentativi e distribuzione tra clienti.
Aggiornato · 8 min
Obiettivi di questa guida
- Precisare il budget
- Limitare la ripresa
- Chiudere gli stati incerti
- Assegnare responsabilità dei tentativi
- Fermare lavoro non più utile
Verifica rapida
- Registrare ambito, header, attesa e budget dei tentativi; provare esaurimento controllato.
- Ritentativi simultanei possono aggravare la saturazione.
Metodo passo passo
- 1
Precisare il budget
Documenta se la quota riguarda account, chiave o risorsa e quante operazioni parallele ammette il client. Una coda illimitata può sovraccaricare il servizio anche con una frequenza media bassa.
Registra unità della quota, concorrenza e dimensione della coda.
- 2
Limitare la ripresa
Con 429 interpreta Retry-After, se presente, e attendi prima di un’altra richiesta. Combina attese crescenti e variazione tra client con un massimo di tentativi e una scadenza complessiva.
Conserva sequenza e orari dei tentativi.
- 3
Chiudere gli stati incerti
Per una scrittura con risposta persa verifica lo stato prima di ripetere. Nei test simulati combina limiti, risposte tardive e annullamento: la coda deve terminare senza duplicare effetti.
Conserva effetti finali e operazioni pendenti.
- 4
Assegnare responsabilità dei tentativi
Mappa applicazione, SDK, proxy e dipendenze con tentativi automatici. Scegli il livello responsabile e disattiva o coordina ripetizioni extra secondo contratto. Conta il tentativo iniziale nel budget. Conserva ID e verifica effetti incerti prima di ripetere operazioni non idempotenti.
Mappa dei tentativi e budget totale per operazione.
- 5
Fermare lavoro non più utile
Definisci scadenza complessiva per attesa, connessione ed elaborazione secondo limiti del client. Rifiuta attività scadute prima della coda. Annullare localmente non prova arresto del server: riconcilia stato. Ripristina traffico gradualmente senza riavviare tutte le code insieme.
Scadenza propagata e prove di arresto o riconciliazione.
Caso di accettazione riproducibile
Esempio fittizio: questi dati non descrivono clienti o risultati osservati.
Vedi dati del caso
{
"http_status": 429,
"retry_after_seconds": 30,
"workers": 20,
"retry_budget": 3,
"retry_budget_scope": "per_worker_retries_excluding_initial_request",
"scheduling_example": {
"response_received_at_seconds": 0,
"illustrative_retry_seconds": [
30,
31,
32,
33,
34
],
"workers_per_second": 4,
"alternative_deadline_seconds": 25,
"total_attempts_if_all_retries_used": 80
}
}Decisione attesa
Rispetta 30 secondi, scagliona i 20 worker e limita i tentativi.
Venti client: distribuire e contare i tentativi
Esempio immaginario: 20 worker ricevono a +0 s una risposta 429 con Retry-After: 30. Gli orari mostrano una possibile distribuzione, senza garantire capacità del server. Ogni worker ha 3 nuovi tentativi oltre alla richiesta iniziale.
| Politica | Calcolo o orario | Effetto |
|---|---|---|
| Ripresa simultanea | 20 × 1 = 20 @ +30 s | Attendere 30 secondi rispetta il ritardo, ma le 20 richieste tornano insieme: il picco può ripetersi. |
| Ripresa distribuita | 4 × 5 = 20 @ +30…+34 s | Quattro richieste al secondo per cinque secondi distribuiscono i 20 tentativi senza ridurne il numero. Questo orario illustrativo non sostituisce una politica di attesa progressiva con variazione casuale. |
| Scadenza a 25 secondi | 25 s < 30 s → 0 | Se il tempo residuo è inferiore ai 30 secondi richiesti, fermare o rinviare secondo il contratto. Non abbreviare l’attesa per rispettare la scadenza. |
| Budget massimo | 20 × (1 + 3) = 80 | Usando tutti i tentativi, 20 richieste iniziali più 60 ripetizioni fanno 80 richieste. Il limite non garantisce successo né ripetizioni prive di effetti indesiderati. |
Varianti fittizie da verificare
Retry-After contiene una data HTTP, non secondi.
Interpretate il formato documentato e verificate l’orologio. Registrate l’attesa calcolata; non sostituite la data con un ritardo arbitrario.
Ogni lavoratore ha un proprio budget di tentativi.
Calcolate anche il carico complessivo. Coordinate la quota condivisa e distribuite i tentativi per evitare un’altra raffica sincronizzata.
Manca la risposta dopo un’operazione con effetti operativi.
Verificate lo stato della fonte di riferimento e il contratto di idempotenza prima di ripetere. Un timeout non dimostra l’assenza di esecuzione.
Evidenze da conservare
- Intestazioni ricevute, formato dell’attesa e orologio usato.
- Budget complessivo dei tentativi e durata massima.
- Identificativo dell’operazione e risultato riconciliato.
Riferimento aggiuntivo : IETF — RFC 9110, Retry-After [EN]
Procedura di verifica
- Registra quota, ambito e budget dei tentativi.
- Esaurisci la quota solo in prove autorizzate.
- Conserva 429, Retry-After e sequenza limitata. Distinguere limite tecnico e risultato operativo: una quota esaurita non deve diventare una risposta di disponibilità nulla.
- Simula senza carico esterno quattro livelli da tre chiamate totali e conta i tentativi.
- Fai scadere un’attività fittizia in coda e verifica che non avvii un’operazione nuova.
- Ripristina lavoro autorizzato gradualmente dopo un guasto simulato e conserva chiamate, scadenze e risultati unici.
API: evitare tentativi moltiplicati tra livelli
Applicazione, SDK, proxy e servizio possono ripetere la stessa chiamata. Quattro livelli fittizi con tre tentativi totali ciascuno producono fino a 81 chiamate alla dipendenza guasta. Aggiungi budget condiviso e scadenza utile ai controlli di quota.
Esempio pratico fittizio
Situazione illustrativa
Registrare ambito, header, attesa e budget dei tentativi; provare esaurimento controllato.
Decisione e prove attese
No. L’operazione con risposta persa richiede una riconciliazione separata; la risposta di un altro tentativo non ne dimostra lo stato.
Indicatori di gestione
| Indicatore | Cosa misura | Prima azione |
|---|---|---|
| Tentativi per operazione | Richieste inviate per una stessa operazione logica | Adattare il budget e fermare i cicli |
| Età della coda | Attesa dall’accettazione della richiesta | Annullare o escalare attività fuori termine |
| Amplificazione delle chiamate | Chiamate alla dipendenza / operazioni iniziali nella stessa finestra | Distinguere tentativi, ripetizioni e sottochiamate previste |
| Lavoro scaduto ammesso | Attività avviate dopo la scadenza utile | Osservare coda, annullamento ed effetti avviati |
Errori comuni
- Ritentativi simultanei possono aggravare la saturazione.
Domande frequenti
429 dimostra che una scrittura precedente non è avvenuta?
No. L’operazione con risposta persa richiede una riconciliazione separata; la risposta di un altro tentativo non ne dimostra lo stato.
Tre tentativi per livello significano tre totali?
No. Quattro livelli fittizi con tre tentativi ciascuno danno fino a 3⁴ = 81 chiamate finali.
La scadenza annulla l’effetto remoto?
Non sempre. Impedisce nuovo lavoro obsoleto; un’operazione remota avviata richiede controllo dello stato e compensazione se possibile.
Retry-After: attesa, budget e nuovi tentativi
Le note dettagliate di questa edizione sono disponibili in inglese.
Decide whether to retry after 429 or 503
A waiting period answers “when?”, not “may this operation be repeated?”. Before retrying, identify the intended effect, read the provider contract and bound total work. An error status or a lost response does not prove that no earlier attempt produced an effect.
Local teaching model with no request, timer, storage or real write. It considers one decision after 429 or 503 using six predefined headers. Dates are read at the fictional instant 22 October 2026, 10:00:00 UTC, assuming an accurate clock. This is neither a complete HTTP parser nor a Stripe client. Obsolete HTTP-date forms, clock skew, transport and SDK-specific policies are outside the calculation.
Twelve ways to read Retry-After
Durations are seconds. Absolute dates need an explicit clock policy; calculations here assume the stated accurate clock. Past dates become zero in this model without permitting an immediate loop. Integer syntax alone does not define a client’s numeric limits.
| Illustrative value | Reading within this scope | Interpretation decision |
|---|---|---|
30 | Non-negative decimal integer: wait 30 seconds after receipt. | This means seconds, not 30 milliseconds. |
0005 | The 1*DIGIT syntax accepts these digits: 5 seconds. | Do not treat the leading zero as octal. |
0 | A declared delay of zero seconds. | Local policy, budgets and permission to repeat still require checking. |
Thu, 22 Oct 2026 10:00:45 GMT | An HTTP date 45 seconds after the fictional receipt time. | Clock uncertainty must not be silently treated as certainty. |
Thu, 22 Oct 2026 09:59:50 GMT | A date 10 seconds in the past; the model uses zero server wait. | A past date requires neither negative waiting nor unlimited replay. |
Field absent | No server wait is supplied. | This model uses its selected local delay, not a normative default. |
1.5 | 1.5 does not meet integer delay-seconds syntax. | Do not silently round it and call the field valid. |
-1 | -1 is not a non-negative decimal integer for this field. | Do not interpret it as a special permission. |
30s | The s unit suffix is not part of delay-seconds syntax. | Seconds are already implied; 30s is not the form 30. |
30, 60 | Two comma-separated durations are not one valid Retry-After value. | Do not split every comma: a valid HTTP date itself contains one. |
Empty value | The field exists but contains neither expected form. | Keep absent and malformed values distinct in records. |
9999999999999999999999 | The digit string meets integer syntax but exceeds this model’s numeric bounds. | Record the local limit without claiming the RFC sets it; never truncate to retry sooner. |
Compare waiting, remaining budget and duplicate risk
Five parameters cover 144 combinations. Fictional policy: wait for the greater of an interpretable server delay and the already selected local delay, then reserve 10 seconds for one attempt. If the remaining budget is insufficient, stop this interactive retry without shortening the server wait. The reserve is not a measured duration and the selected local delay is not a jitter generator.
Teaching decision :
The selected operation type and budget allow considering a retry in this model. This proves neither success nor authorisation on a real service.
- Interpretable server wait
- 30 s
- Selected wait
- 30 s
- Attempt reserve
- 10 s
- Wait + reserve
- 40 s
- Budget margin
- 20 s
Absent or invalid field: this wait comes from local policy. A real API can require a different decision.
Eight reproducible cases
| Fictional situation | Relevant parameters | Decision and limit |
|---|---|---|
| 429, read and 30-second wait | 429 · 30 seconds Conforming GET read Remaining budget after receipt : 60 s | Retry candidate With 60 seconds remaining, 30 + 10 leaves a 20-second margin. |
| Waiting exceeds the budget | 429 · 30 seconds Conforming GET read Remaining budget after receipt : 20 s | Stop this retry With 20 seconds remaining, do not shorten 30 just to force an attempt. |
| Write with unknown contract | 503 · Future date: +45 seconds POST write: retry contract unverified Remaining budget after receipt : 60 s | Check business state Even positive margin does not validate repeating POST. |
| Write with verified contract | 503 · Future date: +45 seconds POST write: retry contract verified Remaining budget after receipt : 60 s | Retry candidate Verified contract is an assumption, not a test of your provider. |
| Invalid fractional value | 503 · Invalid value: 1.5 Conforming GET read Remaining budget after receipt : 20 s | Retry candidate The five-second fallback is a local teaching choice; retain the parse error. |
| Absent field, long local delay | 429 · Field absent Conforming GET read Remaining budget after receipt : 60 s | Retry candidate The 40-second delay comes from the client rather than the server. |
| HTTP date already passed | 503 · Past date: −10 seconds Conforming GET read Remaining budget after receipt : 20 s | Retry candidate The model retains a five-second local delay; the past date triggers no immediate call. |
| Zero does not remove the budget | 429 · 0 seconds Conforming GET read Remaining budget after receipt : 20 s | Stop this retry The 40-second local delay plus reserve exceed the 20 seconds remaining. |
Five distinctions that change client behaviour
| Reference point | Documented meaning | Practical limit |
|---|---|---|
| 429 | RFC 6585 describes too many requests within a period. Retry-After may be present; a 429 response must not be stored by a cache. | The RFC does not set the provider’s counted identity, window or algorithm. |
| 503 | Retry-After can indicate the expected duration of service unavailability. | A 5xx alone does not establish whether a write can be replayed. |
| HTTP idempotence | PUT, DELETE and safe methods are idempotent in their intended effect. | Responses and logs may differ. Controlled POST retries need an additional contract. |
| Retries at multiple layers | Client, SDK and proxy attempts can multiply load. | In a fictional three-layer example with three total attempts at each layer, one request can generate up to 3 × 3 × 3 = 27 calls at the last layer. |
| Jitter and budget | AWS describes spreading retries to avoid synchronised clients. | Randomness makes no write idempotent and replaces neither a deadline nor an attempt limit. |
Five items for retry acceptance evidence
- Method, route, contract version and logical operation identity; keep secrets out of keys and logs.
- Status, raw field, receipt time, interpretation and clock assumption.
- Selected delay, current attempt, remaining budget and the layer actually controlling retries.
- Known or unknown business state, retry key, associated context and parameters, and reconciliation evidence when needed.
- Verified final outcome and user behaviour: understandable waiting, retained input and no button that unintentionally recreates an operation.
Compare idempotency contracts →
Primary sources and limits
The RFCs define the cited HTTP elements. AWS describes design choices and Stripe documents its own APIs. Budgets, local waits, cases and diagrams are educational: they neither measure your service nor execute requests.
- IETF · RFC 9110 — Retry-After et idempotence HTTP · June 2022 · STD 97
§5.6.7; §9.2.2; §10.2.3; §15.6.4 - IETF · RFC 6585 — 429 Too Many Requests · April 2012 · Standards Track
§4 - AWS Builders’ Library · Timeouts, retries, and backoff with jitter · Published 2019-12-05; accessed 2026-10-22
Retries; jitter; timeout scope - Stripe · Idempotent requests · Documentation accessed 2026-10-22
API v1: saved results, parameters, key pruning, execution boundary - Stripe · API v2 overview — Idempotency · Documentation accessed 2026-10-22
POST/DELETE; same API and account/sandbox; 30-day replay window - Stripe · Advanced error handling · Documentation accessed 2026-10-22
Stripe-Should-Retry; status codes; idempotency
References reviewed
GraphQL: errori, liste e dati parziali
Le note dettagliate di questa edizione sono disponibili in inglese.
GraphQL cost and partial results: two separate checks
An authorized query can still be too costly; a partial response measures none of its resource consumption.
- Compare absent data, partial data and data: null.
- Keep the original path even when a parent becomes null.
- Test permissions, quotas and interface states separately.
Explore GraphQL responses and nullability →
GraphQL Specification · September 2025 · Published edition · September 2025
Riferimenti ufficiali
I riferimenti supportano il metodo. Adattare i controlli al proprio contesto; non costituiscono una certificazione. I titoli dei riferimenti originali e i documenti di origine potrebbero essere in un'altra lingua.
Riferimenti consultati il .
- IETF — RFC 6585, HTTP 429
- IETF — RFC 9110, Retry-After
- AWS — Timeouts, retries, and backoff with jitter
- IETF — RFC 9110, Retry-After
- GraphQL Specification · September 2025
- IETF · RFC 9110 — Retry-After et idempotence HTTP
- IETF · RFC 6585 — 429 Too Many Requests
- Stripe · Idempotent requests
- Stripe · API v2 overview — Idempotency
- Stripe · Advanced error handling
