Oswell E. Spencer
есть микросервис на golang который отрабатывает за ~1 - 3мс на любом размере списка при любом кол-ве запросов, как раз под такую задачу писался, никакой php такие цифры не покажет в принципе
это на списке ip/диапазонов в 196к строк
сервис запускается на сервере,
на сайт подключается код
$url = "http://127.0.0.1:8088/validate/";
$ip = getenv('HTTP_CLIENT_IP')?:
getenv('HTTP_X_FORWARDED_FOR')?:
getenv('HTTP_X_FORWARDED')?:
getenv('HTTP_FORWARDED_FOR')?:
getenv('HTTP_FORWARDED')?:
getenv('REMOTE_ADDR');
echo $ip."<br>";
$headers = get_headers( $url.$ip, 1 );
if ($headers[0] == "HTTP/1.1 204 No Content"){
echo "Your IP is Not blocked. Show ADs";
// тут что угодно
echo '<script type="text/javascript">
alert("Hello! I am an alert box!!");
</script>';
}
if ($headers[0] == "HTTP/1.1 200 OK"){
echo "Your IP is Blocked. Forbidden Show ADs";
echo '<script type="text/javascript">
alert("Hello! I am an alert box!!");
</script>';
}
apache benchmark ()
ab -kc 1000 -t 10
http://127.0.0.1:4400/validate/2001:0db8:11a3:09d7:1f34:8a23:07a0:765d
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd,
http://www.zeustech.net/
Licensed to The Apache Software Foundation,
http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Completed 35000 requests
Completed 40000 requests
Completed 45000 requests
Completed 50000 requests
Finished 50000 requests
Server Software: IP-CHECKER
Server Hostname: 127.0.0.1
Server Port: 4400
Document Path: /validate/2001:0db8:11a3:09d7:1f34:8a23:07a0:765d
Document Length: 0 bytes
Concurrency Level: 1000
Time taken for tests: 1.051 seconds
Complete requests: 50000
Failed requests: 0
Keep-Alive requests: 50000
Total transferred: 5400000 bytes
HTML transferred: 0 bytes
Requests per second: 47560.30 [#/sec] (mean)
Time per request: 21.026 [ms] (mean)
Time per request: 0.021 [ms] (mean, across all concurrent requests)
Transfer rate: 5016.13 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 3.8 0 37
Processing: 0 15 26.5 12 673
Waiting: 0 15 26.5 12 673
Total: 0 16 28.2 12 710
Percentage of the requests served within a certain time (ms)
50% 12
66% 15
75% 17
80% 18
90% 23
95% 33
98% 48
99% 63
100% 710 (longest request)
кому интересно велкам в телеграм @RapidCodeLab
p.s. не бесплатно