Alle Beispiele

Beispiele

Ein Token-Bucket-Rate-Limiter, Anfrage für Anfrage

Ein Schwall von fünf Anfragen trifft auf einen Eimer mit drei Tokens: drei kommen durch, zwei bekommen eine 429, und der Eimer füllt sich wieder, sodass ein Client nach einer Pause erneut einen Schwall schicken kann.

Dieses Video wurde mit dem Skill System Design gemacht.

  • 1:05
  • System Design
  • Gesprochen von Iapetus
  • Englisch

Aus einem Prompt erstellt

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

Transkript zum Video

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.

Dein Thema, gezeichnet in etwa einer Minute.

Deine ersten 2 Videos sind kostenlos, je bis zu 1 Minute lang, mit Wasserzeichen. Keine Kreditkarte nötig. Das komplette Produkt, inklusive aller Stimmen und Stile.