A connect component to throttle traffic based on either RPS or response time
node-throttler is a HTTP traffic throttler.
npm install node-throttler
node-throttler is built on top of node-http-proxy. It provides following features.
- throttles traffic by setting a maximum request rate threshold
- throttles traffic by setting a maximum response time threshold
- applies different throttle rates to different URL patterns
- Starts node-throttler
proxy --config <config_file> --log <log_level>
where config is a JSON configuration file and log defines the logging level.
- Runs tests
- Generates JS documents
The configuration file is itself a JSON object consists of following fields.
the port on which the throttler will listen
the host of the remote service to be throttled
the port of the remote service to be throttled
either rps or averesp
defines how the throttle rate key is calculated from the request object. If absent, a constant value is used which means the same threshold value will be applied to all requests
defines how the threshold value is calculated for a request. If it is a constant number, then the value will be applied to all requests
defines the maximum throttle time allowed.
Following fields only apply to rps style
maximum number of requests can be queued before further requests are rejected
Following fields only apply to averesp style
the oldest sample that can be used to compute average response time
the minimum sampel size required to compute average response time
the maximum sampel size required to compute average response time