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):
.
Larger version
Following redirect (1st call, 500ms):
Larger version
Following redirect (subsequent call, no 500ms):
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:
And FF:
EDIT:
More data on the 302 (I selected the wireshark dump where I don't follow redirect):
Frame:
Eth:
IP:
TCP:
HTTP: