What do the surge quota and non-delay parameters in the traffic control rules change individually, who decides whether to queue or reject?
What do the burst quota and nodelay parameters change in the rate limiting rules? Who decides whether to queue or reject? Briefly put: The rate parameter determines the steady-state release rhythm; the burst quota (burst) determines how many extra requests can enter the queue; the nodelay parameter (nodelay) determines whether requests entering the queue should be processed immediately; as for whether a single request is eventually queued or rejected, it depends on whether the number of waiting requests at the time of its arrival has exceeded the burst limit.
What layer does the flow control reach its limit?
The statistical object of flow control is the key, not the path. The official documentation states: This module limits the request processing rate according to the defined key, the typical use is to limit the request rate from a single IP, the implementation method is the leaky bucket. This means that the same key shares the same quota: the key is selected as IP, and multiple real users behind the same exit IP will compete with each other; the key is selected too finely, and the limit is easily bypassed. Choosing the key is the most far-reaching decision in the flow control configuration, and you should first think about whether the granularity of the limit is for each visitor or each call source before taking action.
What does burst change?
According to the official example, setting rate to 1 request per second and burst to 5 means: on average, 1 request is allowed per second, and in addition, up to 5 requests are allowed as bursts.Excess requests will not be rejected immediately, but will be delayed for processing; only when the number of pending excess requests exceeds the burst limit, will the request be terminated and returned with the set status code.So burst is not the cache pool capacity nor the throughput limit, it describes how many excess requests can be queued waiting. Increasing burst allows the site to accommodate longer bursts, but each queued request's waiting time becomes longer, and the risk of client timeouts increases accordingly.
What do nodelay and delay each change?
When no parameters are specified, the excess requests entering the queue are all delayed until space is available in the bucket to process them. The nodelay function is to allow excess requests to not queue up: they still occupy the burst quota but are processed immediately, and are rejected once the quota is exhausted. Delay is a compromise between the two: according to the official documentation, the delay parameter sets the excess requests to be delayed from which number, with the default value of 0, meaning all excess requests are delayed; when set to a non-zero value, the first part of the excess requests are processed immediately, and the rest are queued. The difference between the three is not in the number of requests that can be allowed through, but in the rhythm at which the allowed requests are processed.
Who decides whether to queue or refuse?
The fate of a single request is determined by two switches together: whether the queue is full upon arrival, deciding to queue or reject, this is the boundary drawn by burst;What is returned when rejected, set by the return code instruction, or the default status code is returned if not configured. In the debugging phase, there is also the third switch: the dry-run mode enables non-real interception, only accounting normally in shared memory, suitable for observing how many requests will hit the quota in real traffic before going online.The recommended tuning sequence is to start with dry-run to observe the hit distribution of keys, then determine the rate and burst, and finally decide whether to use nodelay based on the tolerance of the business to latency.
| Parameter | What to change? | What not to change? |
|---|---|---|
| rate | Steady-state throughput rate | Surge capacity |
| burst | Number of excess requests allowed in the queue | Steady-state rate |
| nodelay | Queue request changed to immediate processing | Sudden capacity and rejection boundary |
| delay=N | The first N excessive requests are exempt from delay | Surge capacity |
| dry-run | Only accounting without interception | Accounting口径 |
| Return code instruction | Response status of rejected requests | Interception behavior itself |
Common questions
Ask: Can increasing burst handle high-frequency requests?Answer: Burst only queues excess requests, and requests over the limit are still rejected; facing continuous high-frequency requests, a larger burst will only prolong the waiting time for normal requests.
Ask: Should the key be selected as IP or something else?It depends on the object to be limited. For limiting individual visitors, select IP as an identifier, for limiting interface callers, select account or credential identifier; choosing the wrong key will cause the quota to affect the wrong group of people.
Ask: How do I verify that the rule has taken effect?Answer: First start dry-run to observe the hit count, then switch back to intercept mode, and set the return code to a value that is easy to identify. This way, the client log can separate throttling denials and other errors.