База знаний

Limit frequent requests to search or an API

Эта статья есть на вашем языке: Как ограничить частые запросы к поиску или API

Limit requests per IP to an expensive handler such as search. Choose the threshold from real usage: an office or mobile network can share one public IP.

You need Правила (Rules), spare capacity, and Ограничить (Limit). Replace example.com with your domain. This example covers GET requests to /search and /api/search, rather than every API endpoint. Rules controls currently retain Russian labels.

Create the limit

  1. Open WebShield → example.com → Правила → Добавить правило (Add rule). Name it Search frequency.
  2. Select Ограничить. Set Запросы с одного IP (Requests per IP) to не больше → 20 → в минуту (at most 20 per minute). Set Одновременные запросы (Concurrent requests) to не ограничивать (unlimited).
  3. Under При превышении (On excess), choose Логировать (Log) if available. It counts excess requests without blocking. Otherwise, conduct a small scheduled test using Блокировать (429) (Block).
  4. Set Адрес → Равно (Path equals). Use + Несколько значений (Multiple values) to enter /search and /api/search on separate lines.
  5. Add Метод → В списке → GET (Method in list) in the same group. Use your application's actual method for a POST handler.
  6. Click Сохранить правило (Save rule) and allow synchronization.

Адрес excludes query parameters: /search?q=one and /search?q=two have the same path. Both example paths share this rule's limit for each IP.

Tune the threshold

Test normal search and review Превышений за 24 ч (Excess requests over 24 hours) when logging. Counters may be incomplete. Then select Блокировать (429) and repeat normal usage.

Up to 20 requests may pass initially; capacity then replenishes at an average of 20 per minute. This is not a calendar window. The simulator does not model consumption. Use a limit exception for trusted sources. Distributed requests from different IPs and per-user restrictions also need application controls.

Статья была полезна?