Security Rate-Limit scenarios¶
The following scenarios describe how rate limits are enforced for incoming requests.
Prerequisite¶
- The Security module must be opted in and enabled for your domain.
Details¶
They illustrate system behavior when a ban is not enabled (soft limit) versus when a ban is triggered (hard limit).
Scenario 1: Soft Rate Limit (No Ban)¶
- Policy Example: Limit of X requests per Y minutes per IP
- Behavior:
- Requests are tracked in a rolling time window (e.g., 60 minutes).
- Up to X requests from a single IP are allowed during the window.
- Any request exceeding the limit results in a
429 Too Many Requests
response. - No ban is imposed — the IP is not blocked.
- As older requests fall out of the time window, new requests are allowed again.
- Requests are tracked in a rolling time window (e.g., 60 minutes).
- Flow Example:
- Time 00:00 – 1st request ➜ Allowed
- Time 00:45 – Xth request ➜ Allowed
- Time 00:46 – X+1th request ➜ 429
- Time 01:01 – Oldest request expires ➜ 1 new request allowed
- Time 00:00 – 1st request ➜ Allowed
Scenario 2: Hard Rate Limit (with Ban)¶
- Policy Example: Limit of X requests per Y minutes per IP ➜ Temporary ban (e.g., 15 minutes) if exceeded
-
Behavior:
- Similar to the soft limit: X requests are allowed within the defined window.
- When the limit is exceeded, the IP is temporarily banned for a fixed duration.
- During the ban period, all requests are blocked with
429 Too Many Requests
. - After the ban expires:
- The system re-evaluates the rolling window.
- If the request count still exceeds X, the IP is re-banned.
- If the count is below the limit, the IP is unbanned and requests resume.
-
Flow Example:
- Time 00:00 – 1st request ➜ Allowed
- Time 00:50 – Xth request ➜ Allowed
- Time 00:51 – X+1th request ➜ 429 + IP banned for 15 minutes
- Time 01:06 – Ban expires ➜ System checks window
- If still > X ➜ Re-ban
- If ≤ X ➜ Requests allowed