كل الأمثلة

أمثلة

محدِّد معدّل بدلو الرموز، طلبًا بعد طلب

دفعة من خمسة طلبات تصل إلى دلو فيه ثلاثة رموز: يمرّ ثلاثة، ويُرفض اثنان بالرمز 429، ثم يمتلئ الدلو من جديد فيستطيع عميل انتظر قليلًا أن يرسل دفعة أخرى.

صُنع هذا الفيديو بمهارة تصميم الأنظمة.

  • 1:05
  • تصميم الأنظمة
  • بصوت Iapetus
  • الإنجليزية

صُنع من فكرة

Design a rate limiter with a token bucket. Show a burst of requests and which ones get a 429.

التفريغ النصي للفيديو

Five simultaneous requests can overwhelm your API unless you control the burst.

You start with a client calling your API directly, but sustained traffic pushes utilization to ninety-five percent.

We insert a token bucket limiter before the API, starting with three tokens and refilling one each second.

Each request spends one token, so five arriving together let three through and reject two with HTTP four twenty-nine.

Why reject instead of queueing? Immediate refusal bounds waiting, and clients should retry later with backoff.

The bucket refills continuously up to its capacity, so an idle client can burst again.

The cost is rejected work, and multiple API replicas must share an atomic bucket per client.

Use this at API entry points: the client sends, the limiter admits, and the API handles accepted work.

موضوعك، مرسومًا في دقيقة تقريبًا.

أول 2 من فيديوهاتك مجانًا، مدة كلٍّ منها حتى دقيقة واحدة، مع علامة مائية. لا حاجة إلى بطاقة دفع. المنتج كاملًا، بكل الأصوات والأساليب.