משאבים · 77

מכסות ומגבלות API

המגבלות משפיעות על קיבולת, ניסיונות וחלוקה בין לקוחות.

מעודכן · 8 min

ארכיון מודיעין ריק עם תיקים ומפות איור מערכתי שנוצר באמצעות בינה מלאכותית

מה מדריך זה עוזר להשיג

  • הגדרת התקציב
  • הגבלת ההתאוששות
  • סגירת פעולות לא ודאיות
  • לקבוע אחריות לניסיונות חוזרים
  • לעצור עבודה שאינה מועילה

בדיקה מהירה

  • תעדו היקף, כותרות, המתנה ותקציב ניסיונות; בדקו מיצוי מבוקר.
  • ניסיונות מקבילים עשויים להחמיר עומס.

שיטה שלב אחר שלב

  1. 1

    הגדרת התקציב

    תעדו אם המכסה חלה על חשבון, מפתח או משאב וכמה פעולות מקבילות הלקוח מאפשר. תור ללא גבול יכול להעמיס על השירות גם בקצב ממוצע נמוך.

    רשמו יחידת מכסה, מקביליות וגודל תור.

  2. 2

    הגבלת ההתאוששות

    בתשובת 429 פרשו Retry-After אם קיים והמתינו לפני בקשה נוספת. שלבו המתנה גדלה ופיזור בין לקוחות עם מספר ניסיונות מרבי ומועד סיום כולל.

    שמרו רצף ניסיונות וזמנים.

  3. 3

    סגירת פעולות לא ודאיות

    כשחסרה תשובת כתיבה, בדקו מצב לפני חזרה. בבדיקה מדומה שלבו מכסות, תשובות מאוחרות וביטול; התור צריך להסתיים ללא השפעות כפולות.

    שמרו השפעות סופיות ופעולות ממתינות.

  4. 4

    לקבוע אחריות לניסיונות חוזרים

    מפו ניסיונות אוטומטיים ביישום, SDK, פרוקסי ותלות. בחרו שכבה אחראית ובטלו או תאמו ניסיונות נוספים לפי חוזה. ספרו גם את הניסיון הראשון בתקציב. שמרו מזהה פעולה ובדקו השפעות לא ודאיות לפני חזרה לא אידמפוטנטית.

    מפת ניסיונות ותקציב כולל לפעולה.

  5. 5

    לעצור עבודה שאינה מועילה

    הגדירו מועד כולל להמתנה, חיבור ועיבוד לפי מגבלות הלקוח. דחו משימות שפג זמנן לפני כניסה לתור. ביטול מקומי אינו מוכיח עצירת שרת: התאימו מצב. השיבו תעבורה בהדרגה בלי להפעיל כל התורים יחד.

    מועד מועבר וראיות עצירה או התאמה.

מקרה קבלה שניתן לשחזר

דוגמה בדיונית: הנתונים אינם מתארים לקוח או תוצאה שנצפתה.

הצגת נתוני המקרה
{
    "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
    }
}

החלטה צפויה

המתינו 30 שניות, פזרו ניסיונות של 20 עובדים והגבילו את מספר החזרות.

עשרים לקוחות: לפזר ולספור ניסיונות

דוגמה בדויה: 20 עובדים מקבלים בזמן +0 s תגובת 429 עם Retry-After: 30. הזמנים מציגים פיזור אפשרי ואינם מבטיחים קיבולת שרת. לכל עובד 3 ניסיונות חוזרים בנוסף לבקשה הראשונה.

מדיניותחישוב או תזמוןהשפעה
ניסיון חוזר בו־זמני20 × 1 = 20 @ +30 sהמתנה של 30 שניות מכבדת את ההשהיה, אך כל 20 הבקשות חוזרות יחד והעומס עלול לחזור.
ניסיון חוזר מפוזר4 × 5 = 20 @ +30…+34 sארבע בקשות בשנייה במשך חמש שניות מפזרות 20 ניסיונות בלי להפחית את מספרם. לוח הזמנים להמחשה אינו מחליף מדיניות השהיה גדלה עם שונות אקראית.
מועד סיום אחרי 25 שניות25 s < 30 s → 0אם הזמן שנותר קצר מ־30 השניות הנדרשות, עצרו או דחו בהתאם לחוזה. אל תקצרו את ההמתנה כדי לעמוד במועד.
תקציב מרבי20 × (1 + 3) = 80ניצול כל הניסיונות נותן 20 בקשות ראשונות ועוד 60 חזרות: 80 בקשות. התקרה אינה מבטיחה הצלחה או חזרה בטוחה.

תרחישים בדיוניים לבדיקה

Retry-After מכיל תאריך HTTP ולא מספר שניות.

פרשו את התבנית המתועדת ובדקו את השעון. תעדו את ההמתנה המחושבת; אל תחליפו תאריך בהשהיה שרירותית.

לכל עובד יש תקציב ניסיונות חוזרים משלו.

חשבו גם את העומס המצטבר. תאמו את המכסה המשותפת ופזרו ניסיונות כדי למנוע גל מסונכרן נוסף.

התשובה חסרה לאחר פעולה בעלת השפעה עסקית.

בדקו את המצב הקובע ואת חוזה האידמפוטנטיות לפני הרצה חוזרת. פקיעת זמן אינה מוכיחה שהפעולה לא בוצעה.

ראיות לשמירה

  • כותרות שהתקבלו, תבנית ההמתנה והשעון ששימש.
  • תקציב הניסיונות הכולל ומשך מרבי.
  • מזהה פעולה ותוצאה שהותאמה לרישום.

מקור משלים : IETF — RFC 9110, Retry-After [EN]

נוהל בדיקה

  1. תעדו תחום מכסה ותקציב ניסיונות.
  2. מצו מכסה רק בבדיקה מורשית.
  3. שמרו 429, Retry-After ורצף מוגבל. הבחינו בין הגבלה טכנית לתוצאה עסקית: מכסה שנוצלה אינה אמורה להפוך לתשובה המדווחת על מלאי אפס.
  4. דמו בלי עומס חיצוני ארבע שכבות עם שלוש קריאות כוללות לכל אחת וספרו ניסיונות.
  5. העבירו משימה בדיונית בתור מעבר למועד ובדקו שלא מתחילה פעולה חדשה.
  6. השיבו עבודה מורשית בהדרגה אחרי תקלה מדומה ושמרו קריאות, מועדים ותוצאות ייחודיות.

AWS — Timeouts, retries, and backoff with jitter

API: למנוע ניסיונות מוכפלים בין שכבות

יישום, SDK, פרוקסי ושירות יכולים לחזור על אותה קריאה. ארבע שכבות בדיוניות עם שלושה ניסיונות כוללים לכל אחת יוצרות עד 81 קריאות לתלות שנכשלה. הוסיפו תקציב משותף ומועד שימושי לבקרת מכסות.

דוגמה בדיונית

סיטואציה להמחשה

תעדו היקף, כותרות, המתנה ותקציב ניסיונות; בדקו מיצוי מבוקר.

החלטה וראיות צפויות

לא. הפעולה ללא תשובה דורשת התאמה נפרדת; תשובה לניסיון אחר אינה מוכיחה את מצבה.

מדדי ניהול

מדדמה הוא מודדפעולה ראשונה
ניסיונות לפעולהניסיונות שנשלחו לאותה פעולה לוגיתכוונו תקציב ועצרו לולאות
גיל התורהמתנה מאז קבלת משימהבטלו או הסלימו משימות מעבר למועד
הגברת קריאותקריאות לתלות / פעולות ראשוניות באותו חלוןהפרידו ניסיונות, חזרות וקריאות משנה צפויות
עבודה שפג זמנה התקבלהמשימות שהחלו אחרי המועד השימושיבדקו תור, ביטול והשפעות שהחלו

טעויות נפוצות

  • ניסיונות מקבילים עשויים להחמיר עומס.

שאלות נפוצות

האם 429 מוכיח שכתיבה קודמת לא בוצעה?

לא. הפעולה ללא תשובה דורשת התאמה נפרדת; תשובה לניסיון אחר אינה מוכיחה את מצבה.

האם שלושה ניסיונות לשכבה הם שלושה בסך הכול?

לא. ארבע שכבות בדיוניות עם שלושה ניסיונות כוללים נותנות עד 3⁴ = 81 קריאות אחרונות.

האם פקיעת משימה מבטלת השפעה מרוחקת?

לא בהכרח. היא מונעת עבודה חדשה לא נחוצה; פעולה שהחלה דורשת בדיקת מצב ופיצוי אם אפשר.

Retry-After: המתנה, תקציב והחלטת ניסיון חוזר

הערות המקורות המפורטות זמינות באנגלית במהדורה זו.

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.

מעבדת רשת בדיונית ללא אנשים, עם ציוד על שולחן כהה בתאורה ענברית. איור מערכתי שנוצר באמצעות בינה מלאכותית
Generated, people-free conceptual network laboratory from the editorial collection. It depicts neither real infrastructure nor a throughput test.

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.

Twelve ways to read Retry-After
Illustrative valueReading within this scopeInterpretation decision
30Non-negative decimal integer: wait 30 seconds after receipt.This means seconds, not 30 milliseconds.
0005The 1*DIGIT syntax accepts these digits: 5 seconds.Do not treat the leading zero as octal.
0A declared delay of zero seconds.Local policy, budgets and permission to repeat still require checking.
Thu, 22 Oct 2026 10:00:45 GMTAn 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 GMTA date 10 seconds in the past; the model uses zero server wait.A past date requires neither negative waiting nor unlimited replay.
Field absentNo server wait is supplied.This model uses its selected local delay, not a normative default.
1.51.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.
30sThe s unit suffix is not part of delay-seconds syntax.Seconds are already implied; 30s is not the form 30.
30, 60Two comma-separated durations are not one valid Retry-After value.Do not split every comma: a valid HTTP date itself contains one.
Empty valueThe field exists but contains neither expected form.Keep absent and malformed values distinct in records.
9999999999999999999999The 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 : Retry candidate

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

Eight reproducible cases

Eight reproducible cases
Fictional situationRelevant parametersDecision and limit
429, read and 30-second wait429 · 30 seconds

Conforming GET read

Remaining budget after receipt : 60 s
Already selected local delay : 5 s

Retry candidate

With 60 seconds remaining, 30 + 10 leaves a 20-second margin.

Waiting exceeds the budget429 · 30 seconds

Conforming GET read

Remaining budget after receipt : 20 s
Already selected local delay : 5 s

Stop this retry

With 20 seconds remaining, do not shorten 30 just to force an attempt.

Write with unknown contract503 · Future date: +45 seconds

POST write: retry contract unverified

Remaining budget after receipt : 60 s
Already selected local delay : 5 s

Check business state

Even positive margin does not validate repeating POST.

Write with verified contract503 · Future date: +45 seconds

POST write: retry contract verified

Remaining budget after receipt : 60 s
Already selected local delay : 5 s

Retry candidate

Verified contract is an assumption, not a test of your provider.

Invalid fractional value503 · Invalid value: 1.5

Conforming GET read

Remaining budget after receipt : 20 s
Already selected local delay : 5 s

Retry candidate

The five-second fallback is a local teaching choice; retain the parse error.

Absent field, long local delay429 · Field absent

Conforming GET read

Remaining budget after receipt : 60 s
Already selected local delay : 40 s

Retry candidate

The 40-second delay comes from the client rather than the server.

HTTP date already passed503 · Past date: −10 seconds

Conforming GET read

Remaining budget after receipt : 20 s
Already selected local delay : 5 s

Retry candidate

The model retains a five-second local delay; the past date triggers no immediate call.

Zero does not remove the budget429 · 0 seconds

Conforming GET read

Remaining budget after receipt : 20 s
Already selected local delay : 40 s

Stop this retry

The 40-second local delay plus reserve exceed the 20 seconds remaining.

Five distinctions that change client behaviour

Five distinctions that change client behaviour
Reference pointDocumented meaningPractical limit
429RFC 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.
503Retry-After can indicate the expected duration of service unavailability.A 5xx alone does not establish whether a write can be replayed.
HTTP idempotencePUT, 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 layersClient, 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 budgetAWS 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.

References reviewed

GraphQL: שגיאות, רשימות ונתונים חלקיים

הערות המקורות המפורטות זמינות באנגלית במהדורה זו.

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

הפניות רשמיות

הפניות תומכות בשיטה. התאימו את הבדיקות להקשר שלכם; הן אינן הסמכה. כותרות הפניות ומסמכי המקור המקוריים עשויים להיות בשפה אחרת.

תאריך בדיקת המקורות .