From: Eric Dumazet <eric.dumazet@gmail.com>
To: Leandro Lucarella <leandro.lucarella@sociomantic.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: Doubts about listen backlog and tcp_max_syn_backlog
Date: Tue, 22 Jan 2013 09:13:20 -0800 [thread overview]
Message-ID: <1358874800.3464.4002.camel@edumazet-glaptop> (raw)
In-Reply-To: <20130122165929.GH4608@sociomantic.com>
On Tue, 2013-01-22 at 17:59 +0100, Leandro Lucarella wrote:
> What I'm seeing are clients taking either useconds to connect, or 3
> seconds, which suggest SYNs are getting lost, but the network doesn't
> seem to be the problem. I'm still investigating this, so unfortunately
> I'm not really sure.
>
A SYN packet or a SYN-ACK packet can be lost in the network.
> > A serious rewrite of LISTEN code is needed, because the current
> > implementation doesn't scale :
> >
> > The SYNACK retransmits are done by a single timer wheel, holding the
> > socket lock for too long. So increasing the backlog to 2^16 or 2^17 is
> > not really an option.
> >
> > Hash table are nice, but if we have to scan them, holding a single lock,
> > they are not so nice.
>
> So, the queue is really a hash table, then? So using any (2^n)-1 would
> be a bad idea because when the backlog is next to full, the hash table
> will be really slow? Is that why the + 1 is there? Is assuming everyone
> will use a power of 2 an thus having a load factor of 0.5 at most?
>
The kind of hash tables we use are power of two.
The size of hash table has little effect, its automatic, to try to get
an average of one item per hash slot, or less. Even if we had 10 items
per slot, it would not be a big deal.
What is important is the backlog, and I guess you didn't increase it
properly. The somaxconn default is quite low (128)
# sysctl -w net/ipv4/tcp_max_syn_backlog=4096
net.ipv4.tcp_max_syn_backlog = 4096
# sysctl -w net.core.somaxconn=4096
net.core.somaxconn = 4096
Then make sure your server use a big enough listen(..., backlog)
parameter.
next prev parent reply other threads:[~2013-01-22 17:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-22 16:10 Leandro Lucarella
2013-01-22 16:45 ` Eric Dumazet
2013-01-22 16:59 ` Leandro Lucarella
2013-01-22 17:13 ` Eric Dumazet [this message]
2013-01-22 18:17 ` Rick Jones
2013-01-22 18:42 ` Leandro Lucarella
2013-01-22 22:01 ` Rick Jones
2013-01-23 10:47 ` Leandro Lucarella
2013-01-23 19:28 ` Rick Jones
2013-01-24 12:22 ` Leandro Lucarella
2013-01-24 18:44 ` Rick Jones
2013-01-24 19:21 ` Leandro Lucarella
2013-01-25 6:12 ` Nivedita SInghvi
2013-01-25 10:05 ` Leandro Lucarella
2013-01-28 2:48 ` Nivedita Singhvi
2013-01-28 5:21 ` Vijay Subramanian
2013-01-28 14:40 ` Leandro Lucarella
2013-01-28 13:08 ` Leandro Lucarella
2013-01-28 2:49 ` Nivedita Singhvi
2013-01-23 20:48 ` Vijay Subramanian
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=1358874800.3464.4002.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=leandro.lucarella@sociomantic.com \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®