[QUESTION] How to make parallel / multiple requests at once? #1911
-
I have an array of files (10'000+ files) which i need to download from the server. Im not sure how i can implement so that the requests so they don't block each other like make one request -> wait until downloaded -> start next request. Is it possible to somehow download all the files in parallel / multiple requests to increase the performance? also is it possible to keep the connection alive since all the requests are made to the same server? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Your question is not directly related to Got, but it's more of a general JavaScript question. Got returns a promise. There are many ways to run promises concurrently. I would recommend using something like |
Beta Was this translation helpful? Give feedback.
Your question is not directly related to Got, but it's more of a general JavaScript question. Got returns a promise. There are many ways to run promises concurrently. I would recommend using something like
p-map
as it lets you limit the concurrency. What the concurrency limit should be really depends on the server. You have to make sure you won't get banned by the server owner.