2021年2月4日星期四

JavaScript: How to speed up API calls when one API call lasts very long?

I have an API call that lasts very long, about 5 to 20 minutes, as it is dependent on third party APIs. What happens is that it waits for the other process to inform its job completeion and in the process I make it sleep for quite some time, after each try. This causes other API calls to slow down, as I believe JavaScript is single threaded this takes much of resources.

Is there any way I can remove this API from the call stack till the time it is sleeping and enhace the efficiency for other API calls?

Some additional context after receiving comments:

What I mean is that, as I have to depend on the 3rd party API call I add a sleep function that lasts for about 30 seconds. This is done to check for the success of the API call. During these 30 seconds of interval this process does no useful task but still takes up resources.

https://stackoverflow.com/questions/66056889/javascript-how-to-speed-up-api-calls-when-one-api-call-lasts-very-long February 05, 2021 at 10:45AM

没有评论:

发表评论