I wrote a certain web interface with a large number of scripts called via ajax. He wrote on localhost, then uploaded to the Internet to see how it would work there. Seconds after 15-20 active "poking" on the buttons, the server stopped responding to requests, spitting at me 503 error.
The code, as I realized, really turned out to be quite lanky. In addition to 1-3 necessary requests to the database, there are 2-3 additional requests to check whether the person has the right to perform this action. (we take out id from the authorization table, then from the user table we take information about the user, then we look at the rights of the person in the privilege table ...)
What can I do to avoid 503 errors in my case **? **
I was thinking into the session at the first check to push something like $_SESSION['can_i_do_this']=time()+180;
and do the next check only after 3 minutes. But then it turns out that if during these three minutes a person suddenly has privileges, then for some time he will “sit” with incorrect data, but this is not very good.