Frequent access to the server

Hello everyone. 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.
Restrict the user to 15 seconds if the hit rate is less than 5 seconds.
Can’t imagine what variant methods could be. I thought that it was possible to take the last record from the database and look at the time of adding, but this is not a functional method, and besides, it is not profitable, since a query to the database must be made anyway.

What options for solving such a problem are there? Thank you.

Answer 1, authority 100%

You can either do this using nginx/Apache/iptables or not do it at all.
Because you have a goal to reduce the load on the server from too “active” users. It can be said from DDOS. Just one of the protections against DDOS is a ban on many requests from 1 IP.

Answer 2

A request counter reset via CountDownTimerevery N minutes in the JavaScript client side that sends the AJAX request can help. True, this will not save you from the fact that the user can refresh the page via CTRL + F5, then the timer will restart or someone will access your server from outside the browser. In this case, you need to configure the HTTP server.

Leave a reply

Please enter your comment!
Please enter your name here