3. Security and Validation

throttle

Version

Throttles incoming traffic by delaying requests and/or capping how many are processed concurrently, to protect a backend from overload. With delay set, every request is held briefly before it continues. With maxThreads set, a request that arrives while the limit is already reached is rejected with 503 once no slot frees up. See the examples under examples/routing-traffic/throttle.

Example Configuration

api:
port: 2000
flow:
- throttle:
maxThreads: 10
busyDelay: 3000
target:
url: https://api.predic8.de
api:
   port: 2000
   flow:
     - throttle:
         maxThreads: 10
         busyDelay: 3000
   target:
     url: https://api.predic8.de

Syntax

throttle:
busyDelay: <number>
delay: <number>
maxThreads: <number>
throttle:
  busyDelay: <number>
  delay: <number>
  maxThreads: <number>

Attributes

NameRequiredDefaultDescriptionExamples
busyDelayfalse0When maxThreads is reached, the maximum time in milliseconds a request waits for a slot to free up before it is rejected with 503. 0 rejects immediately.3000
delayfalse0Milliseconds to hold every request before it continues. 0 disables the delay.1000
maxThreadsfalse0Maximum number of requests processed concurrently. A request arriving while the limit is reached waits up to busyDelay for a slot to free up and, if none does, is rejected with 503. 0 means unlimited.5

Can be used in