When does the error occur?
A 503 error usually occurs when the resources on the hosting account have been exceeded. Each hosting account has some limitations (even when packages are labeled "unlimited" they have even greater limitations that lead to this error). These limits do not include space, monthly flow, number of domains, number of bases and the like, but how much your account will use server resources.
Each server is limited (a server is actually the same as your computer, only its purpose is different, but it also has limited space, processor, and RAM). In order to prevent one account from taking up all the server's resources and thereby endangering the entire server and other accounts, these restrictions exist.
Limits consist of, limited number of processes, how many processors, writes to the database or to the disk as well as reads.
When you happen to hit the upper limit for some of these you get a 503 message.
Note that this error does not appear constantly, but occasionally. So when it happens to appear and you refresh the page and your site opens, it's completely crazy. Because the occupation varies from many things and thus it is free or reports an error.
How can he make sure he doesn't appear again?
The solution is a bit more complicated. First you need to determine what causes it. Is there a bug (failure) on the site that leads to exceeding the resources or is it a question of a large number of visits?
In order to determine this, you first need to check whether there is an error on the site.
We have an article for analyzing errors on websites error 500.
If nothing is written there, it means that it is not due to errors, but due to a large number of plugins (plugins in the case of wordpress) that read a lot from the database or on disk, or you simply have a large number of visits in the same second.
As for the number of visits, you can easily check google analytics, which allows you to see the number of visits on the site in real time. When you see that, say, 1000 visits at the same time and you occasionally get the error 500, then it means that the number of visits is high and it is time to optimize the site or to switch to a larger package.