TCP tuning in Linux for non-blocking socket connection over long-path WAN
I have a Linux C-program with non-blocking TCP socket which
working well in local LAN network. But when used on long-path WAN
it has problem. The issue is NOT the increased latency by itself
(this was expected!) but that it start spending huge time inside OS
calls doing actual writing to non-blocked socket:
'strace' command's showing that actual write to non-blocking socket
with 5MB data is not returning back for ~20 sec!
[pid 28521] 03:29:57.153841 <... writev resumed> ) = 5120162 <22.158727>
[pid 28521] 03:30:19.697228 <... writev resumed> ) = 5120162 <21.291031>
[pid 28521] 03:30:38.645879 <... writev resumed> ) = 5120162 <18.348090>
What I was expecting that because of the WAN network latency the writing
will have congestion and returns with partial send within milliseconds,
then the same thread can handle multiple connections, but that's
not the case here and the thread is actually block with each write.
So the question here is why non-blocking connection socket's getting
block in write() call for so long to write WHOLE message rather than
only part of it? How can we change code or do tuning to obtain the
normal non-blocking behavior.
OS Info: Linux RHEL 4 with default configuration and default socket
options settings.
|