Hello. I thought about the problem with the load on the server. I think we need to make a limit on the frequency of requests, in particular with ajax. Limit the user to 15 seconds if the frequency of one call is less than 5 seconds. I can not imagine what methods options may be. I thought that you can take the last record from the database and look at the time of addition, but this is not a functional method, and besides, it is not profitable, since the query to the database in any case needs to be done.

What are the options for solving this problem? Thank.

    2 answers 2

    This is either done using nginx / Apache / iptables or not at all. Because your goal is to reduce server load from too "active" users. It can be said from DDOS. Just one of the DDOS protection is a ban from 1 IP to many requests.

      The request counter, which is CountDownTimer via CountDownTimer every N minutes in the client-side JavaScript that sends the AJAX request, can help. However, this will not save you from the fact that the user can refresh the page through CTRL + F5, then the timer will go again or someone will turn to your server not from the browser. In this case, you need to configure the HTTP server.

      • From the server side (PHP) is it possible to implement? - Chosen
      • You can try to get the counter of the number of calls sent to the PHP script as a GET parameter and the server would decide what to do if the parameter is more than a certain number, while on the client side, save it as a cookie and load this cookie every time the user updates page. Something like this. - igumnov pm
      • one
        Not safe. = ( - Selected