netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: Alexander Vodomerov <alex@sectorb.msk.ru>
Cc: netdev@vger.kernel.org
Subject: Re: high latency with TCP connections
Date: Wed, 30 Aug 2006 10:27:27 -0700	[thread overview]
Message-ID: <20060830102727.11e11453@localhost.localdomain> (raw)
In-Reply-To: <20060830100734.GA22235@isil.ipib.msu.ru>

On Wed, 30 Aug 2006 14:07:34 +0400
Alexander Vodomerov <alex@sectorb.msk.ru> wrote:

> Hello!
> 
> I'm writing an application that is working over TCP. Total traffic is
> very low (~ 10 kb/sec), but performance is very bad. I've tried to
> investigate problem with tcpdump and strace, and it shows that
> application does multiple writes, but TCP buffers them and send after
> some delay (about 40 msec). Due to nature of my application, it is
> essential to send any available data ASAP (decreased bandwidth is not
> important). I've set TCP_NODELAY option on socket, but it doesn't help.

Linux TCP implements "Appropriate Byte Count" (ABC) and this penalizes
applications that do small sends. The problem is that the other side
may be delaying acknowledgments.  If receiver doesn't acknowledge the
sender will limit itself to the congestion window. If the flow is light,
then you will be limited to 4 packets.

> We've written a simple program to reproduce the effect. It sends 10
> small packets, then sleeps for 0.1 sec. Another node tries to receive
> data. Strace shows that 2 packets are sent immediately and other 8 are
> grouped together and delayed by 40 msec.
> 
> It is interesting that this effect can be seen not only on Ethernet
> links, but on loopback also (with the same magic constant of 40 msec).
> 
> Here is a test run:
>   server (should be run first):
> $ ./a.out 1 5000
> Server: begin send_all
> Server: total time 14.216441
>   client:
> $ ./a.out 2 5000 localhost
> Client: connected to localhost:5000
> Client: begin receive_all
> Client: total time 14.223265
> 
> Expected time is 10.0 sec (instead of 14.0 sec).
> If packets are received more often (DELIM constant is set to 1 or 2)
> then effect disappear.
> 
> Is this a desired behaviour? How can I specify that packets should be
> sent really immediately after write?
> 
> Some people reported that this program runs in 9.997 sec when run on
> FreeBSD.
> 
> Please cc me on replies, as I'm not subscribed to mailing list.
> 
> With best regards, 
>    Alexander.
> 

> 
> void send_all(unsigned long delay)
> {
> 	int i;
> 	char buf[1024];
> 	printf("Server: begin send_all\n");
> 	for (i = 1; i < TOTAL_SENDS; ++i) {
>                 write(sock, buf, 1);

Expecting any performance with one byte write's is silly.

  reply	other threads:[~2006-08-30 17:27 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-30 10:07 high latency with TCP connections Alexander Vodomerov
2006-08-30 17:27 ` Stephen Hemminger [this message]
2006-08-30 21:39   ` David Miller
2006-08-30 22:04     ` Stephen Hemminger
2006-08-30 23:00     ` Rick Jones
2006-08-31  8:14     ` Alexander Vodomerov
2006-08-31 15:44       ` Sridhar Samudrala
2006-08-31 18:22     ` Kelly Burkhart
2006-08-31 19:40       ` Rick Jones
2006-08-31 21:08       ` Ian McDonald
2006-08-31 21:46   ` Alexey Kuznetsov
2006-08-31 22:14     ` Stephen Hemminger
2006-08-31 22:44       ` David Miller
2006-08-31 23:29         ` Alexey Kuznetsov
2006-08-31 23:57           ` David Miller
2006-09-01  3:23             ` Stephen Hemminger
2006-09-01  3:39               ` Ian McDonald
2006-09-01  6:23                 ` David Miller
2006-09-01  9:44             ` Pekka Savola
2006-09-01  9:49               ` David Miller
2006-09-01  9:47             ` Alexey Kuznetsov
2006-09-01 11:00               ` Evgeniy Polyakov
     [not found]                 ` <20060901090046.69b3d583@localhost.localdomain>
2006-09-01 20:55                   ` [PATCH] tcp: turn ABC off Stephen Hemminger
2006-09-02  7:22                     ` Evgeniy Polyakov
2006-09-02  8:10                       ` Herbert Xu
2006-09-04  9:10                 ` high latency with TCP connections Alexey Kuznetsov
2006-09-04 16:00 ` [PATCH][RFC] " Alexey Kuznetsov
2006-09-05 17:55   ` Rick Jones
2006-09-05 22:13     ` Alexey Kuznetsov
2006-09-18  7:39     ` David Miller
2006-09-18 17:11       ` Rick Jones
2006-09-18 20:41         ` Alexey Kuznetsov
2006-09-18 21:24           ` Rick Jones
2006-09-18 22:51             ` Alexey Kuznetsov
2006-09-19  0:37               ` Rick Jones
2006-09-22 13:46                 ` Alexey Kuznetsov
2006-09-22 17:15                   ` Rick Jones
2006-09-18  7:31   ` David Miller
2006-09-18 10:37     ` Alexey Kuznetsov
2006-09-18 13:56       ` David Miller
2006-09-20 22:44         ` Stephen Hemminger
2006-09-20 22:47           ` David Miller
2006-09-20 22:55             ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060830102727.11e11453@localhost.localdomain \
    --to=shemminger@osdl.org \
    --cc=alex@sectorb.msk.ru \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).