1

I recently started to bench my java webserver application and I detected a very weird 500ms network latency on the client side.

When I request my webserver for the first time, I get the following timing:

$ curl --max-redir 0 -w "%{time_total}\n" http://ip_to_my_domain/abc
0.527

Then all the subsequent calls will take the expected time:

$ curl --max-redir 0 -w "%{time_total}\n" http://ip_to_my_domain/abc
0.067
$ curl --max-redir 0 -w "%{time_total}\n" http://ip_to_my_domain/abc
0.062
$ curl --max-redir 0 -w "%{time_total}\n" http://ip_to_my_domain/abc
0.063

After searching on Google and SO, I discovered this post where TCP delayed ACK is mentioned.

Here is my own wireshark analysis:

Not following redirect (1st call, 500ms): not following the redirect. Larger version

Following redirect (1st call, 500ms): Following redirect Larger version

Following redirect (subsequent call, no 500ms): Following redirect Larger version

If this is indeed the the manifestation of the TCP delayed ACK and since I obviously I don't have access to the client OS/browser configuration, what can I do on the server side code or network configuration to avoid that behavior?

I have access to the webserver application (running jetty 8.1.1) code and the servers/lb/firewall configurations.

Thanks in advance for your help.

EDIT:

Same behavior on Chrome: Chrome

And FF: Firefox

EDIT:

More data on the 302 (I selected the wireshark dump where I don't follow redirect):

Frame: Frame details

Eth: Eth details

IP: IP details

TCP: TCP details

HTTP: HTTP details

Community
  • 1
  • 1
MichelT
  • 31
  • 4
  • 1
    What is your specific question? (Don't comment, just edit it in). – Anubian Noob Jun 10 '14 at 22:53
  • JSPs get compiled on the first request to them. You can pre-compile, but it use to be a pain to get the container to recognize the compiled jsps. It was several years ago that we tried pre-compiling so things might have changed since then. – hooknc Jun 10 '14 at 23:08
  • I believe that curl time_total is giving you the full round trip response time. This will include any work on the server side. If the first time a client connects to the server it needs to do extra work, like set up session data or create some new records for this new client then that might explain the extra timing. – Mick Jun 10 '14 at 23:14
  • @hooknc there is no JSP involved. The only thing the servlet is doing is returning a 302 with a redirect url + setting a cookie – MichelT Jun 11 '14 at 00:12
  • @Mick I am interested in the the total time since I want to know exactly what the total latency is. I attached the wireshark sc to make it clear that something is going on at the network lower level. – MichelT Jun 11 '14 at 00:15
  • Do you see this from clients other than curl? – Brett Okken Jun 11 '14 at 00:55
  • Yes, I updated the post with FF and chrome timing screenshots – MichelT Jun 11 '14 at 01:25
  • Do you have more info on the 302 message returned (without revealing your domains etc if that is an issues) - for example is there a content length value and what is it? – Mick Jun 11 '14 at 22:41
  • I added all the information I have for this particular message – MichelT Jun 12 '14 at 00:34

0 Answers0