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
|`enabled`| Enables the dynamic rate limiting feature. | No |`false`|
40
-
|`window_multiplier`| The factor by which the previous window rate is multiplied to get the dynamic limit. | No |`1.3`|
41
40
|`window_duration`| The time window duration for calculating traffic rates. | No |`2m`|
41
+
|`default_window_multiplier`| The default factor by which the previous window rate is multiplied to get the dynamic limit. Can be overridden by providing a `window_configurator` extension. | No |`1.3`|
42
+
|`window_configurator`| An optional extension to calculate window multiplier dynamically based on unique keys. | No ||
42
43
43
44
### Dynamic Rate Limiting Deep Dive
44
45
@@ -59,7 +60,14 @@ Where:
59
60
60
61
*`previous_rate`: The rate of traffic in the previous window (normalized per second).
61
62
*`static_rate`: The configured `rate` in the main configuration.
62
-
*`window_multiplier`: A factor applied to the previous window rate to determine the dynamic limit.
63
+
*`window_multiplier`: A factor applied to the previous window rate to determine the dynamic limit. It is derived based on the following formula:
@@ -72,7 +80,7 @@ Let's walk through a few examples to illustrate the behavior of the dynamic rate
72
80
Assume the following configuration:
73
81
74
82
*`window_duration`: 2m
75
-
*`window_multiplier`: 1.5
83
+
*`window_multiplier`: 1.5 (with no `window_configurator` provided)
76
84
*`rate`: 1000 requests/second (this is our `static_rate`)
77
85
78
86
#### Scenario 1: Initial Traffic
@@ -296,3 +304,18 @@ Telemetry and metrics:
296
304
297
305
* `ratelimit.resolver.failures` — total number of resolver failures
298
306
* `ratelimit.dynamic.escalations` — number of times dynamic rate was peeked (attributes: `class`, `source_kind`, `success`)
307
+
308
+
### Throttling rate based on custom logic using `window_configurator`
309
+
310
+
The `window_configurator` option configures a custom OpenTelemetry Collector extension to dynamically choose a window multiplier for the current period. The value is the extension ID (the extension's configured name). The extension MUST implement the `WindowConfigurator` interface. The multiplier can be used to scale up the rate limit from previous window (by returning a multiplier greater than `1`) or scale down the rate limit from previous window (by returning a multiplier less than `1`, greater than `0`). If the extension returns a negative value then the `default_window_multiplier` will be used. Note that the dynamic limit MUST be at least the configured `static_rate`, ensuring a minimum level of throughput. An example configuration including the window configurator:
311
+
312
+
```yaml
313
+
processors:
314
+
ratelimiter:
315
+
dynamic_limits:
316
+
enabled: true
317
+
window_duration: 2m
318
+
default_window_multiplier: 1.5
319
+
# This is an example window configurator. It doesn't exist.
0 commit comments