Rate limits
Learn how to configure rate limits for your resource, how they work, and where they are placed in the filtering hierarchy.
|
Rate limits are available for Anti-bot and Anti-DDoS protection modes. This feature is enabled on request. If the |
About the rule group
Description
Rate limits are a rule group that limits how often one IP address can send requests to a specific URI path.
Example: you set a limit of 5 requests per minute from one IP address for the /login page. If that IP address sends 5 or more requests within one minute, the system blocks it for 5 minutes.
Rate limits are useful when you need to:
-
Protect endpoints from overload.
-
Reduce the risk of business-logic abuse.
-
Add an extra safeguard in case bots learn to imitate traffic from trusted sources.
Configure an allowed request frequency for the required URI paths. Normal traffic passes through, while IP addresses with abnormal activity are blocked temporarily.
How rate limits work
-
Create a limit rule and specify:
-
The URI path to which the rule applies.
-
The number of requests from one IP address at which blocking starts within the selected period.
-
The time for which an IP address is blocked when the limit is reached.
-
-
The system counts the requests each IP address sends to this URI path.
-
If the number of requests reaches the limit, the system blocks the IP address for the specified time.
-
When the block duration ends, the IP address can send requests again.
How rate limits differ from enforcement rules
In the Custom rules section, you can set request limits with two rule groups: Rate limits, described in this article, and Enforcement.
The difference is the scope of settings and the way the rules work. Rate limits are a focused feature that temporarily limits the number of requests from one IP address to specific URI paths. Enforcement is more flexible: a limit is one of the rule conditions, and when a request matches the conditions, protection applies the selected action.
The table below compares the two rule groups in the context of request limits to help you choose the right one.
| Rate limits | Enforcement | |
|---|---|---|
Setup speed |
Faster |
Slower |
When to choose |
You need to limit frequent requests to a specific URI path. |
You need to limit frequent requests based on a flexible set of characteristics, listed in the row below. |
Traffic parameters available for setting a limit |
URI path |
URI path, country, ASN, query string, headers, cookies, method, user agent, IP addresses or subnets, SP hash, and other parameters |
What you can limit |
The number of requests from one IP address |
|
What happens when the limit is reached |
The IP address that sent requests to the specified URI path is blocked for the configured time. New requests from this address do not pass until the block ends. |
The action you select is applied to requests that match the conditions and exceed the limit. You can select any of the following actions:
The limit works as an additional rule condition. You can change the limit behaviour so that the action is applied before, rather than after, the limit is reached. DetailsYou can select one of the following modes:
|
Can take DDoS attack status into account |
No |
Yes. You can specify when the limit applies: always, only during a DDoS attack, or while there is no DDoS attack. |
Available in Anti-bot mode |
Yes |
Yes |
Available in Anti-DDoS mode |
Yes |
No |
Where rate limits are placed in the filtering hierarchy
Protection filters each request in stages: first with one filtering mechanism, then with the second, third, and so on. The list below shows where rate limits are placed.
|
The set of stages differs depending on the protection mode you purchased: Anti-bot or Anti-DDoS. |
-
Anti-bot
-
Anti-DDoS
If two filtering mechanisms conflict, the mechanism that runs first is applied. For example, the white list is above rate limits. This means that all requests from an IP address in the white list are allowed, even if they exceed the limit.
Recommendations
-
Create separate rules for important URI paths. This makes it easier to choose an appropriate limit and reduces the risk of accidentally blocking normal requests.
-
Do not set limits too low for pages users visit frequently.
-
Before configuring a limit, assess the load on the URI path using charts in Request logs. Consider normal request frequency and peak values to set a limit that does not interfere with legitimate traffic.
-
You can use stricter limits for login, registration, and password recovery pages.
-
If a URI path is often used for AJAX requests, make sure the limit does not interfere with the interface.
Configuration
Open Rate limits
Go to Application protection → Resources. Click the ellipsis (…) next to the resource for which you want to configure a limit and select Custom rules. The section opens, where you can find the Rate limits tab.
Create a limit rule
-
Click
+ Create limit rule. The rule creation window opens. Complete the remaining steps there.
-
In the
Rule namefield, enter a clear name that describes the limit and helps you find it in the list.Examples:
-
Login form protection. -
API request rate limiting.
-
-
Specify the URI path to which the rule applies.
You can select an operator. It determines how the system compares the URI in a request with the value in the rule:
-
=: the rule applies only to the specified path. Example:URI path = /login. -
starts with: the rule applies to the specified path and all nested paths. Example:URI path starts with /api/.
You can specify multiple URI paths. To do this, add paths using
+ or.The limit is shared by all URI paths specified in the rule.
Example. You add the following conditions to the rule:
-
URI path = /commentsorURI path starts with /contact. -
A limit of
15requests per60seconds.
If one IP address sends 10 requests to
/comments, 3 requests to/contact, and 2 requests to/contact/presswithin one minute, the system counts them together. The total limit of 15 requests is reached, so the IP address is blocked temporarily. -
-
Set the Rate limit parameters:
-
Requests: the number of requests from one IP address at which blocking starts. For example,20. -
Period (seconds): the time in seconds during which the system counts requests. For example,60for one minute.
-
-
Specify the Block duration: the number of seconds for which the system blocks the IP address when the limit is reached. For example,
3600for one hour. -
Click
Create rule. The rule appears in the list and starts working.
Configuration examples
The examples below show how to configure a limit rule. Click a heading to expand its description.
Example 1: limit requests to a specific URI path
Rule settings:
-
URI path = /api/v1/orders. -
Requests:100. -
Period (seconds):60. -
Block duration (seconds):120.
The rule counts only requests to /api/v1/orders. If one IP address sends 100 or more requests within 60 seconds, the system blocks the IP address for 120 seconds.
Example 2: limit requests to a group of URI paths
Rule settings:
-
URI path starts with /api/v1/. -
Requests:200. -
Period (seconds):60. -
Block duration (seconds):120.
The rule counts requests to all paths that start with /api/v1/, for example:
-
/api/v1/catalog; -
/api/v1/search; -
/api/v1/products.
If one IP address sends 200 or more requests within 60 seconds to paths that match the rule, the system blocks the IP address for 120 seconds.
Management
On the Rate limits tab, you can view all created limit rules. You can manage rules directly from the list:
-
Edit: click the ellipsis (
…) at the end of the row and selectEdit. In the window that opens, change the required rule settings. -
Delete: click the ellipsis (
…), selectDelete, and confirm deletion.