How can I limit the number of requests allowed on the server using PHP? the server can accept up to five requests from a single IP address every 2 seconds. How to implement it ------ solution ------------------ it should be reasonable. You can determine the route and ip ------ solution ------------------ the simplest way is to calculate the last access time and the number of visits to the latest access time. of course, you need to write data to the database-how to limit the number of requests allowed on the server
Can I use PHP to restrict the server to receive up to five requests from a single IP address every 2 seconds.
How to implement it?
------ Solution --------------------
It should be reasonable. You can determine the route and ip address.
------ Solution --------------------
The simplest method is to calculate the number of visits between the last access time and the last access time. of course, you need to write data to the database.
------ Solution --------------------
PHP is used to implement session
------ Solution --------------------
Session_start ();
If (isset ($ _ SESSION ['lasttime']) & time ()-$ _ SESSION ['lasttime'] <2)
Exit;
Else
$ _ SESSION ['lasttime'] = time ();
------ Solution --------------------
Generally, IP addresses and sessions are bundled together.
The number of visits in a few seconds exceeds 100,000.
This is a failure. if this happens, your server has crashed.
------ Solution --------------------
If the COOKIE time is not set, the browser closes the SESSION and becomes invalid.
------ Solution --------------------
Discussion
By the way, what is the actual relationship between SESSION and browser enabling and disabling,
------ Solution --------------------
Discussion
Reference:
Generally, IP addresses and sessions are bundled together.
The number of visits in a few seconds exceeds 100,000.
This is a failure. if this happens, your server has crashed.
Oh, thank you for your guidance !!
A few simple words seem to solve the problem. I originally planned to exist in the database. each IP address corresponds to a record, and then there are access traffic, time, and other fields ..
In fact, I'm curious. what the predecessors said about the crash is probably normal. I really have no idea about this ..
Most ......