there is a task to minimize the time to http request in Java. I use the Unirest library in the project, however, a similar situation occurs with the libraries async-http-client and okhttp
What is the essence: The first post request to the server takes about a second, but all subsequent requests in the main thread are completed in 200ms already, which I consider to be a good result. But I could not achieve the same speed while sending several requests at the same time. If you use the Unirest library functionality for asynchronous requests, then each request will take ~ 700ms, which is much slower than the required 200.
The second option that I tried is to make server requests in different Threads. At first, I still perform the first long request in the main thread, and then I post my requests for threads, in one of which I get 200ms per request, but in the other one I get over 700ms.
Question: Is there a way to perform parallel queries without losing the speed of the query itself?