I have already posted a similar question, but we've narrowed down the error and now have more specific information.
This error happens in every part of our organization's REST API which are located in the services3 server, we have another organization and also tested creating new organizations which are not in services3 and the error could not be emulated.
We are testing and trying to workaround this error for almost a month now, managed to narrow it down but no solution I'm afraid.
The 503 error comes from AWS CloudFront, which basically means an overload on the server.
We first saw the error while using the JS API, but the error is directly at the API REST point, you can get the error just by navigating to the API through your browser. It is seemingly random, but it has a higher chance of happening when you do several queries in a row, in our case it happens almost 100% of the time since we're gathering the attachments of a layer in batch, and you must do a separate attachment query for each feature.
It also has a high chance of happening when an user opens an web application with several different layers.
The only workaround we found was to, when an certain URL fails on a browser tab, you open that same URL in a new tab, refresh it, go back to the original tab and it should work, so the server limitation seems to be related to client sessions.
I do believe it's an overload on the services3 machine, it's an old server that most sample layers from ESRI are hosted in, if you create a new AGOL account right now it will be at services9 (as of today), which will give you no errors.
This error has completely halted our development cicle and application deployment.
I'm posting here as our local support is not direct with ESRI and it's taking way too long of a time to get any progress.
You can see a similar discussion here : ArcGIS Online Reader/Writer Error: Code 503 - FME Knowledge Center