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.

  • And what kind of server? Look at the logs, on what falls? - Chad

1 answer 1

503 error - this is usually not enough server resources. You, young man, think about where the weak point is. According to the information described here it is difficult to draw conclusions, one can only give advice on diagnosing the problem.

  1. If a server console is available, then you can once again try to overwhelm the server and view the top or htop output while doing so.
  2. Pay attention to whether files, resources, etc. are open. Maybe something is processed recursively.
  3. Try manually feeding the sql queries of your program with the explain statement.
  4. Show at least something.
  • @metoban, Hostinger free hosting, I was looking for the logs in the first place, I did not find it. Recursion is definitely not. Everything works fine, if "work slowly." As I understand it, the problem is in a large number of requests. I remember once a couple of years ago I tried to write ajax chat using a polling (Interval - one second), so I ran into the same problem. As a result, they even banned me on that hosting) I think in my situation the best solution would be to take all the work on the shoulders of the browser, and then at the end of one request to save the result of the work. - sinedsem