@@ -290,48 +290,25 @@ rate-limiting {
290
290
}
291
291
```
292
292
293
- #### ` services.$NAME.rate-limiting.timeout `
294
-
295
- The ` timeout ` parameter is used to set the total timeout for acquiring all rate limiting tokens.
296
-
297
- If acquiring applicable rate limiting tokens takes longer than this time, the request will not be
298
- forwarded and will respond with a 429 error.
299
-
300
- This parameter is mandatory if the ` rate-limiting ` section is present.
301
-
302
- This is specified in the form:
303
-
304
- ` timeout millis=TIME ` , where ` TIME ` is an unsigned integer
305
-
306
- ** Implementation Note** : The rate limiting timeout is a temporary implementation detail to limit
307
- requests from waiting "too long" to obtain their tokens. In the future, it is planned to modify
308
- the leaky bucket implementation to instead set an upper limit on the maximum "token debt", or
309
- how many requests are waiting for a token. Instead of waiting and timing out, requests will instead
310
- be given immediate feedback that the rate limiting is overcongested, and return a 429 error immediately,
311
- instead of after a given timeout.
312
-
313
- When this change occurs, the ` timeout ` parameter will be deprecated, and replaced with a ` max-token-debt `
314
- parameter instead.
315
-
316
293
#### ` services.$NAME.rate-limiting.rule `
317
294
318
295
Rules are used to specify rate limiting parameters, and applicability of rules to a given request.
319
296
320
297
##### Leaky Buckets
321
298
322
299
Rate limiting in River uses a [ Leaky Bucket] model for determining whether a request can be served
323
- immediately, or if it should be delayed (or rejected) . For a given rule, a "bucket" of "tokens"
324
- is created, where one "token" is required for each request.
300
+ immediately, or if it should be rejected. For a given rule, a "bucket" of "tokens" is created, where
301
+ one "token" is required for each request.
325
302
326
303
The bucket for a rule starts with a configurable ` tokens-per-bucket ` number. When a request arrives,
327
304
it attempts to take one token from the bucket. If one is available, it is served immediately. Otherwise,
328
- the request waits in a first-in, first-out order for a token to become available .
305
+ the request is rejected immediately .
329
306
330
307
The bucket is refilled at a configurable rate, specified by ` refill-rate-ms ` , and adds a configurable
331
308
number of tokens specified by ` refill-qty ` . The number of tokens in the bucket will never exceed the
332
309
initial ` tokens-per-bucket ` number.
333
310
334
- Once a refill occurs, requests may become ready if a token becomes available .
311
+ Once a refill occurs, additional requests may be served .
335
312
336
313
[ Leaky Bucket ] : https://en.wikipedia.org/wiki/Leaky_bucket
337
314
@@ -361,7 +338,7 @@ potentially defeating the objective of accurate rate limiting.
361
338
When multiple rules apply to a single request, for example rules based on both source IP address,
362
339
and the URI path, then a request must claim ALL applicable tokens before proceeding. If a given IP
363
340
address is making it's first request, but to a URI that that has an empty bucket, it will immediately
364
- obtain the IP address token, but be forced to wait until the URI token has been claimed
341
+ obtain the IP address token, but the request will be rejected as the URI bucket claim failed.
365
342
366
343
##### Kinds of Rules
367
344
0 commit comments