You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/learning-center/api-gateway-rate-limiting.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,7 @@ The token bucket algorithm maintains a bucket of tokens for each rate-limited en
38
38
Token bucket allows short bursts up to the bucket capacity while enforcing an average rate over time. This makes it well-suited for APIs where occasional traffic spikes are acceptable but sustained overuse is not.
39
39
40
40
**Pros:** Permits controlled bursting, simple to implement, low memory footprint.
41
+
41
42
**Cons:** Burst size must be tuned carefully; overly generous bursts can still overwhelm backends.
42
43
43
44
### Leaky Bucket
@@ -47,6 +48,7 @@ The leaky bucket algorithm processes requests at a fixed rate, queuing excess re
47
48
Leaky bucket is ideal for backends that require strictly uniform request rates, such as third-party APIs with their own rate limits or services with fixed connection pools.
48
49
49
50
**Pros:** Produces perfectly smooth output, prevents backend overload from bursts.
51
+
50
52
**Cons:** Higher latency for bursty traffic due to queuing, queue size requires tuning.
51
53
52
54
### Sliding Window
@@ -56,6 +58,7 @@ The sliding window algorithm divides time into overlapping windows and counts re
56
58
For example, if the window is 60 seconds and the current position is 40 seconds into the window, the algorithm weights 33% of the previous window's count and 100% of the current window's count to determine if the limit is exceeded.
57
59
58
60
**Pros:** Accurate rate enforcement without boundary spikes, reasonable memory usage.
61
+
59
62
**Cons:** Slightly more complex to implement than fixed window.
60
63
61
64
### Fixed Window
@@ -65,6 +68,7 @@ The fixed window algorithm divides time into non-overlapping intervals and count
65
68
Fixed window is the simplest algorithm but has a well-known boundary problem: a client can make double the intended rate by clustering requests at the end of one window and the beginning of the next. Despite this limitation, fixed window remains widely deployed due to its simplicity and low overhead.
66
69
67
70
**Pros:** Minimal memory and computation, easy to understand and debug.
71
+
68
72
**Cons:** Boundary burst problem allows temporary rate doubling.
0 commit comments