My node server does a cache warmup on start up. The data is requested from an external webservice.
All of this is done asynchronously, which means that (currently) all requests (about 300) are done almost instantly (as quickly as node can loop), and then each response is handled when it arrives (as per what I understand the node async paradigm to be).
This causes a problem because it triggers the DDoS protection on the external webservice.
So I somehow need to limit the frequency with which requests are sent out during this phase (when the server is running, requests are not done this often and never in this quick succession).
But: How do I reconcile this with the async programming that node "needs"? If I use setTimeout it will just delay the requests to a later time, but because it's done in a loop, they will still happen almost in the same instant.
Using await so each call is only triggered when the previous one was received feels too much of a limit. I can do parallel requests, just not that many in that short of a timespan.
How can I get around this?