I am working on a Java
server which needs to send multiple HTTP get
requests to another server and process the responses and wrap them up. Currently I am using synchronous
way to do this like in Java
:
for(Request request: requestList){
Response response = client.send(request);
}
This works, but it takes a long time if the requestList
's size is big, since it is doing it sequentially: send a request, wait for the response and then send next.
I am wondering, is there a way to speed this up? I am thinking if using multiple thread to send multiple request will do the trick? Or maybe not, since the total response time is fixed for a certain amount of requests.
Any idea or explanation, why or why not this will work will be helpful. I am using Java
.