Answer the question
In order to leave comments, you need to log in
How to limit queries in MySQL + PHP per unit of time?
Good day!
As in any relatively functional project, we have requests to the database (changing the password, issuing any data, creating messages, changing some settings, etc.)
For global and serious requests, such as authorization and registration, we can put a captcha, but putting it everywhere where there is at least some query to the database seems like a completely terrible solution. I would like to limit the ability to query the database for a person (by ip, username or whatever), for example, so that a person cannot update information on a page (via Ajax + php + mysql) more than 1 time in 2 seconds ...
Yes Are there any simple solutions without storing a separate table with data on who did what and when?
Answer the question
In order to leave comments, you need to log in
session yuzay. in it remember the time of the last request to the database
Maybe at the level of the web server to solve the issue?
for example, if you have nginx, then this can help you
nginx.org/ru/docs/http/ngx_http_limit_req_module.html
upd
database - serves data.
application - serves the dynamics.
web server - serves connections.
your task is NOT at the application or data level, but at the connection level. of course, you can solve it at the application level through cookies / sessions / some other crutches, but it’s wrong that the application logic depends on such an indicator as the number of requests per second. it is more correct from the point of view of architecture to solve on the server.
Yuzay for example cookies. Increase cookies by +1 when requested. If there is more than a certain value, then write, they say, the blocking and the user can no longer do anything. Etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question