I am writing a tool to compare with a web application. The problem that I encountered is that the first request to the server always takes significantly longer than subsequent requests. I ran into this problem with apache http client 3.x, 4.x and google http client . Apache http client 4.x shows the biggest difference (the first request takes about seven times longer than subsequent ones). For Google and 3.x it is about 3 times longer.
My tool should be able to compare concurrent requests with threads. I cannot use one instance, for example. HttpClient and call it from all threads, because it throws a Concurrent exception. Therefore, I have to use a separate instance in each thread, which will only perform one request. This dramatically changes the overall results.
I do not understand this behavior. I do not think that this is due to the caching mechanism on the server, because a) the web application in question does not use caching (as far as I know), and b) this effect also manifests itself upon the first request to www.hostxy.com and subsequently www. hostxy.com/my/webapp.
I use System.nanoTime () just before and after calling client.execute(get) or get.execute() respectively.
Does anyone have an idea where this behavior comes from? Do these httpclients perform caching? I would be very grateful for any hints.
source share