Create a new ThrottleLayer with given bandwidth and burst.
bandwidth: the maximum number of bytes allowed to pass through per second.burst: the maximum number of bytes allowed to pass through at once.Validation (bandwidth and burst must be greater than 0) is handled by the Rust core layer.
Throttle layer
Add a bandwidth rate limiter to the underlying services.
Throttle
There are several algorithms when it come to rate limiting techniques. This throttle layer uses Generic Cell Rate Algorithm (GCRA) provided by Governor. By setting the
bandwidthandburst, we can control the byte flow rate of underlying services.Note
When setting the ThrottleLayer, always consider the largest possible operation size as the burst size, as the burst size should be larger than any possible byte length to allow it to pass through.
Examples
This example limits bandwidth to 10 KiB/s and burst size to 10 MiB.