Stable operation of an online store directly affects sales, customer trust, and advertising campaign efficiency. However, even a modern server can face overload due to mass automated requests, malicious bots, and DDoS attacks.
Online stores with large catalogs, complex product filtering systems, and dynamic page generation are particularly vulnerable to such attacks.
The AI-WEB team developed its own mechanism to protect websites from excessive automated requests at the software level. During practical implementation of the solution at one of the online stores, the server Load Average indicator decreased from approximately 5 to 1 without upgrading server equipment.
Why product filters become targets of DDoS attacks
Modern online stores allow customers to select products by manufacturer, price, country of origin, characteristics, and other parameters.
Each combination of filters can generate a separate dynamic page, which requires the server to perform a series of operations:
- process the incoming HTTP request;
- run program code;
- generate SQL queries;
- perform product search by characteristics;
- calculate the number of results;
- generate an HTML page.
When regular customers use these functions, it represents normal load. Problems arise when automated systems start massively generating different parameter combinations.
In large catalogs, the number of possible combinations can be extremely large. This also complicates caching, since requests often don't repeat.
We discuss the architecture of such systems in more detail in the article «How to organize a catalog with 10,000–20,000+ products».
Why traditional IP address blocking is not always effective
One of the common ways to combat automated attacks is to block IP addresses from which excessive requests originate.
However, modern distributed attacks can use a large number of addresses from different countries. At the same time, each individual address sends relatively few requests, but their total number creates significant load.
Traditional blocking mechanisms have a number of disadvantages:
- continuous increase in IP address blacklists;
- risk of blocking ordinary customers;
- additional load during collection and analysis of statistics;
- limited effectiveness against distributed attacks;
- risk of blocking search engines;
- need for regular cleaning of outdated lists.
Automatic blocking of entire subnets is particularly dangerous, since ordinary users can be restricted along with malicious traffic.
When developing our own solution, we decided to focus not on accumulating information about potentially dangerous IP addresses, but on selective protection of the most resource-intensive functions of the site.
Our own AI-WEB protection technology
The protection mechanism developed by the AI-WEB team operates at the PHP level and can be integrated into web projects based on CMSDK.
The main principle is early verification of incoming requests before launching the main business logic of the site and performing complex database operations.
The system determines whether the user is accessing a regular page or trying to use resource-intensive functionality.
For regular pages, no additional geographical restrictions are applied. For protected functions, the IP address is checked against a specially formed database of allowed networks.
The geography of access is determined in accordance with the target market of a particular business.
For example, for an online store that operates mainly in Ukraine, it is possible to allow Ukrainian customers and verified search engines to use complex product filters, while restricting access for other IP addresses.
System operation principle
- Receiving an incoming HTTP request.
- Determining the type of requested page.
- Checking if protection needs to be applied.
- Verifying IP address against a database of allowed ranges.
- Passing the allowed request to the CMS.
- Rejecting unwanted requests before resource-intensive operations are performed.
In this way, the server does not waste resources on generating filtering results for requests that do not comply with established access rules.
This approach is one of the technical optimization methods we apply during web development and website modernization.
Optimized database of allowed IP addresses
An important component of development is a specialized IP address database.
Instead of needing to determine each visitor's country using a full geographic database, a compact list of allowed networks is used.
The solution architecture provides support for the following groups of addresses:
- IPv4 and IPv6 of target countries;
- Googlebot;
- Bingbot;
- ChatGPT search robots;
- other allowed search and information services.
IP addresses are stored as network ranges, which allows reducing data volume and optimizing the verification process.
To maintain database relevance, automated updates are provided.
Special attention is paid to verifying search robots. Simple User-Agent analysis is not sufficient, since an automated system can represent itself as Googlebot or another known robot. A more reliable approach is to verify IP addresses against officially published ranges of the respective services.
Selective protection instead of blocking the entire website

One of the key advantages of AI-WEB development is the ability to restrict individual functions without completely disabling the website.
| Online store functionality | Operating mode |
|---|---|
| Homepage | Available to all users |
| Product categories | Available to all users |
| Product cards | Available to all users |
| Information pages | Available to all users |
| Advanced product filters | Selective protection |
| Internal search | Possibility of separate protection |
| Shopping cart and order placement | Separate access rules |
| Search bots | Access according to allowed ranges |
Protection rules can be adapted to the architecture of a specific online store.
For business, this means the ability to maintain the availability of main pages and sales functions even during increased automated activity.
Practical implementation of online store protection in PHP
To protect against mass automated requests, the AI-WEB team developed a two-level traffic filtering mechanism that integrates directly into index.php before loading CMSDK and connecting to MySQL.
Formation of the database of allowed IP addresses
Based on open sources, a database of allowed IPv4 addresses has been formed.
|
Source |
Number of records |
|---|---|
|
Ukrainian IPv4 |
2666 |
|
|
317 |
|
Bingbot |
29 |
|
OAI-SearchBot (ChatGPT) |
39 |
|
Claude |
14 |
|
PerplexityBot |
21 |
|
Applebot |
24 |
|
DuckDuckBot |
486 |
|
QwantBot |
1 |
|
Total number |
3597 |
|
After optimization |
3084 |
After sorting and merging adjacent and duplicate ranges, a compact database of 3084 records was obtained.
To check IP addresses, a binary search algorithm is used, which requires no more than 12 iterations instead of sequential enumeration of the entire database.
Connecting the protection system
The solution consists of two files:
-
allowed-ipv4.php— database of allowed IP addresses with binary search function. -
antis.php— request rate limiting via Memcache.
Connection in index.php:
$isAllowedIpv4 = require __DIR__.'/antis/allowed-ipv4.php';
if ($isAllowedIpv4($_SERVER['REMOTE_ADDR'] ?? '')) {
require_once __DIR__.'/antis/antis.php';
antis_check();
} else {
header('HTTP/1.0 403 Forbidden');
exit;
}Files:
<?php
function antis_check()
{
static $checked = false;
if ($checked || PHP_SAPI === 'cli') {
return;
}
$checked = true;
$limit = 10;
$interval = 10;
$host = '127.0.0.1';
$port = 11211;
if (!class_exists('Memcache', false)) {
return;
}
$memcache = new Memcache();
if (!@$memcache->pconnect($host, $port, 1)) {
return;
}
$now = time();
$window = (int) floor($now / $interval);
$root = !empty($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : __DIR__;
$key = 'antis:v3:' . md5($root) . ':' . $window;
// Атомарное увеличение; add не перезаписывает существующий ключ.
$count = @$memcache->increment($key, 1);
//echo 'count = '.$count;
if ($count === false) {
if (@$memcache->add($key, 1, 0, $interval * 2)) {
$count = 1;
} else {
$count = @$memcache->increment($key, 1);
}
}
// При недоступности кеша сайт продолжает работать.
if ($count === false) {
return;
}
if ($count > $limit) {
header('HTTP/1.0 403 Forbidden');
exit;
}
}
// Совместимость со старым index.php; повторного подсчёта нет.
function antis_collect()
{
antis_check();
}
allowed-ipv4.php
Operating Principle
Protection is activated only for URLs containing characters typical of product filters.
-
IP address is checked for membership in allowed ranges.
-
Unwanted requests are rejected with HTTP 403 code.
-
For allowed IPs, the number of requests is additionally controlled via Memcache.
-
Regular website pages work without additional checks.
Request counters are stored in RAM. The system does not use MySQL, does not create blacklists, and does not accumulate visitor IP addresses.
As a result of practical implementation, server load was reduced by approximately 80% without equipment upgrades, Nginx configuration changes, or connecting external DDoS protection services.
The current implementation supports IPv4. If needed, the system can be extended with IPv6 support and adapted for other geographic markets.
This AI-WEB development demonstrates how software architecture optimization allows increasing the stability of an online store without increasing server infrastructure costs.
Advantages of AI-WEB's proprietary solution
The proposed architecture allows adapting protection mechanisms to the specifics of a particular business.
Main advantages of the solution:
- early rejection of unwanted requests;
- reduced load on MySQL;
- selective protection of functionality;
- no need to maintain large blacklists;
- support for authorized search engines;
- ability to adapt to different countries;
- integration into existing PHP projects;
- ability to work without connecting external traffic filtering services.
To implement a basic mechanism, it is not necessary to change the domain's DNS servers or move the site to another hosting platform.
What attacks can such a system stop
The development is primarily focused on protecting the application layer, also known as Layer 7.
| Threat Type | Protection Capabilities |
|---|---|
| Bulk requests to product filters | Selective blocking |
| Generation of unwanted URL combinations | Access restriction |
| Automated load on MySQL through the website | Load reduction |
| Bulk requests from unauthorized IPs | Early rejection |
| Attacks from authorized IP addresses | Require additional restrictions |
| Network DDoS attacks | Require network-level protection |
| Server internet channel overload | Requires external infrastructure countermeasures |
PHP protection is not a complete replacement for network DDoS countermeasure systems. However, it can be an effective component of a multi-layered security system.
If necessary, the solution can be supplemented with Nginx-level restrictions, caching, network rules, and external protection services.
Which web projects benefit from this development
Selective protection from automated requests is especially relevant for:
- online stores with large assortments;
- online product catalogs;
- marketplaces;
- B2B portals;
- sites with multi-level filters;
- services with dynamic information search;
- web platforms with complex business logic.
More materials on creating and optimizing trading platforms are available in the section «Online stores and e-commerce».
Development and implementation of website protection systems
At AI-WEB, we consider security, performance, and website stability as components of a unified technical architecture.
Our own software development allows us to adapt solutions to the specifics of web projects, analyze the causes of overload, and eliminate them at the software level.
We work not only on creating new websites, but also on modernizing existing systems, optimizing databases, improving performance, and protecting resource-intensive functionality.
If your online store is facing constant server overload, massive bot requests, or unstable catalog operation, contact AI-WEB specialists for problem analysis and selection of an appropriate technical solution.