My .Net and Java application needs to make many simultaneous requests to a web service which takes a notable length of time to reply. Consequently there may be thousands of outstanding HTTP requests at any one time. To implement this I could have a single thread generate many asynchronous HTTP requests and handle the responses but I want to understand any alternatives which allow synchronous HTTP requests to be made without requiring thousands of threads to be used because of the associated resource cost. Any solution must avoid threads being blocked waiting for HTTP responses.
My question has two parts:
1) Can Threadpools be used to do this? I know I can queue my jobs in the threadpool queue and the threadpool will process them as and when it is able to but can the threadpool worker threads avoid being blocked waiting for the http response? Can they go and process other jobs while they wait?
2) Is there some other way I can achieve this while retaining the simplicity of the HTTP synchronous API call.
Regards
By themselves, no.
Are you talking about the client side HTTP call API? If so, there is a way to do this, by using an asynchronous server-side implementation.