简体   繁体   中英

How to limit requests per minute?

Is there a way to limit requests per minute from every unique person accessing my website?

Somehow they increase my CPU to 100% and MySql crash.

Im only using using session session_start()

I found something on internet but i dont know how to make it work

if(!isset($_SESSION['check']))
$_SESSION['check'] = 0;
    
$_SESSION['check'] = $_SESSION['check'] + 1;
 if($_SESSION['check'] > 50)
die('error');

You might want to abandon limiting requests per minute.

With MySQL and MariaDB, the intended limiter is

max_connections=50

within your my.cnf (or my.ini) in [mysqld] section.

This one configuration variable will prevent more than 50 concurrent connections and if you had your error log working, log_warnings=2 will provide information when this limit is exceeded. Most people have enough server power to add ten % to their limit, as needed. If not, invest in RAM, it is inexpensive today.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM