Rate Limit
tcp socket speed limit
yaml value: mix
Basically it consists of 3 fields:
shift_millis | shift
type: int
The time slice we use to count is 2 ^ N milliseconds, where N is set by this key and should be in range [0 - 12]. If N is 10, and the time slice is 1024ms. If omitted, this means the limit is not set.
upload | north | upload_bytes | north_bytes
type: humanize usize
This sets the upload bytes in the time slice. 0 means delay forever.
download | south | download_bytes | south_bytes
type: humanize usize
This set the max download bytes in the time slice. 0 means delay forever.
The yaml value type can be in varies formats:
-
This will set upload and download to the same value, with shift_millis set to 10.
map
The keys of this map are the fields as described above.
udp socket speed limit
yaml value: mix
Basically it consists of 4 fields:
shift_millis | shift
type: int
The time slice we use to count is 2 ^ N milliseconds, where N is set by this key and should be in range [0 - 12]. If N is 10, and the time slice is 1024ms. If omitted, this means the limit is not set.
upload_bytes | north_bytes
type: humanize usize
This sets the upload bytes in the time slice. 0 means no limit.
download_bytes | south_bytes
type: humanize usize
This set the max download bytes in the time slice. 0 means no limit.
upload_packets | north_packets
type: int [usize]
This set the max upload packets in the time slice. 0 means no limit.
download_packets | south_packets
type: int [usize]
This set the max download packets in the time slice. 0 means no limit.
The yaml value type can be in varies formats:
-
This will set upload and download bytes to the same value, set shift_millis to 10 and disable check on packets.
map
The keys of this map are the fields as described above.
global stream speed limit
yaml value: mix
Basically it consists of 3 fields:
replenish_interval
type: humanize duration
Set the replenish interval value.
default: 1s
replenish_bytes
type: humanize usize
Set the replenish byte size to add when replenish_interval reached.
max_burst_bytes
type: humanize usize
Set the max byte size.
default: the same as replenish_bytes
The yaml value type can be in varies formats:
-
This is the same as set replenish_bytes to be the same value.
map
The keys of this map are the fields as described above, and the replenish_bytes field is always required.
Added in version 1.9.6.
global datagram speed limit
yaml value: mix
Basically it consists of 5 fields:
replenish_interval
optional, type: humanize duration
Set the replenish interval value.
default: 1s
replenish_bytes
optional, type: humanize usize
Set the replenish byte size to add when replenish_interval reached.
If not set, no bytes limitation will be applied.
replenish_packets
optional, type: humanize usize
Set the replenish packet count to add when replenish_interval reached.
If not set, no packets limitation will be applied.
max_burst_bytes
optional, type: humanize usize
Set the max byte size.
default: the same as replenish_bytes
max_burst_packets
optional, type: humanize usize
Set the max packet count.
default: the same as replenish_packets
The yaml value type can be in varies formats:
-
This is the same as set replenish_bytes to be the same value.
map
The keys of this map are the fields as described above, and at least one of replenish_bytes or replenish_packets field should be set.
Added in version 1.9.6.
request limit
yaml value: mix
It consists of 2 fields:
shift_millis | shift
type: int
The time slice we use to count is 2 ^ N milliseconds, where N is set by this key and should be in range [0 - 12]. If N is 10, and the time slice is 1024ms. If omitted, this means the limit is not set.
requests
type: usize
This sets the max requests in the time slice. 0 is not allowed.
rate limit quota
yaml value: mix
It consists of 3 fields:
rate
type: nonzero u32
If int or str without any unit, the default unit will be per second.
Supported units for str:
/s, per second
/m, per minute
/h, per hour
replenish_interval
type: humanize duration
Construct a quota that replenishes one cell in a given interval. The default max_burst value is 1 is its not specified along with this option.
max_burst
Adjusts the maximum burst size for a quota to construct a rate limiter with a capacity for at most the given number of cells
Note
rate and replenish_interval is conflict with each other, the latter one in conf will take effect.
The yaml value for u32 limit quota can be in varies formats:
simple rate
Just the rate value. The max_burst value is the same as the one set in the rate.
map
The keys of this map are the fields as described above.
random ratio
yaml value: f64 | str | bool | integer
Set a random ratio between 0.0 and 1.0 (inclusive).
For str value, it can be in fraction form (n/d), in percentage form (n%), or just a float string.
For bool value, false means 0.0, true means 1.0.
For integer value, only 0 and 1 is allowed.