I am trying to disable Java's HTTP keep-alive for performance testing. I am assuming that if I disable the keep-alives, Java should do less handshakes. However, after adding -Dhttp.keepalive=false
to the JVM args (which should disable the keep-alive), I see no difference when tracing the packets in wireshark.
I made a small java code to test it:
public static void main(String[] args) throws Exception {
String httpsURL = "https://www.google.com";
URL myUrl = new URL(httpsURL);
for(int i = 0; i < 3; i++) {
System.out.println("Sending packet");
HttpsURLConnection conn = (HttpsURLConnection) myUrl.openConnection();
InputStream is = conn.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
Thread.sleep(10000);
}
}
I was testing it on the JDK I got from here: https://adoptopenjdk.net/releases.html?variant=openjdk11&jvmVariant=openj9#x64_mac
So I tried running with the following 2 commands:
openj9-11/Contents/Home/bin/java HelloWorld
openj9-11/Contents/Home/bin/java -Dhttp.keepAlive=false HelloWorld
The results from Wireshark (when filtering by ip == 172.217.10.100; i.e.: Google's IP) for both runs are identical. - Wireshark (tracing first command) screenshot: https://i.stack.imgur.com/2at6l.jpg - Wireshark (tracing second command) screenshot: https://i.stack.imgur.com/zT24V.jpg
I was expecting to get less handshakes when tracing the second command. Am I doing something wrong or are the results expected?