From: Nick Jones <nick.jones@network-box.com>
To: Tom Herbert <therbert@google.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net,
netdev@markandruth.co.uk, eric.dumazet@gmail.com
Subject: Re: [PATCH 0/5]: soreuseport: Bind multiple sockets to the same port
Date: Fri, 25 Jan 2013 13:06:14 +0800 [thread overview]
Message-ID: <510212C6.6060303@network-box.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1301221142300.26333@pokey.mtv.corp.google.com>
On Wednesday, January 23, 2013 03:49 AM, Tom Herbert wrote:
...
>
> The motivating case for so_resuseport in TCP would be something like
> a web server binding to port 80 running with multiple threads, where
> each thread might have it's own listener socket. This could be done
> as an alternative to other models: 1) have one listener thread which
> dispatches completed connections to workers. 2) accept on a single
> listener socket from multiple threads. In case #1 the listener thread
> can easily become the bottleneck with high connection turn-over rate.
> In case #2, the proportion of connections accepted per thread tends
> to be uneven under high connection load (assuming simple event loop:
> while (1) { accept(); process() }, wakeup does not promote fairness
> among the sockets. We have seen the disproportion to be as high
> as 3:1 ratio between thread accepting most connections and the one
> accepting the fewest. With so_reusport the distribution is
> uniform.
>
There is another model for accepting connections in a multi threaded
application that I experimented with: dup the listener fd one time for
each thread, then each thread register the fd in its own epoll set, then
listen and accept independently.
Has anyone had experience with this strategy? I'm sure that the
SO_REUSEPORT feature will lead to much better performance, I'm just
asking from the point of view of one who doesn't have that feature
available. I wonder if this strategy is like a poor mans SO_REUSEPORT?
The advantages of this approach were not fully proved in practise, I
didn't produce any hard figures, but in theory it was appealing:
- no bottleneck of using a single thread for accepting then distributing
connections (in addition to latency of waiting for the job handling
thread to receive the event and start its work)
- connections were used in the thread in which they were accepted, thus
locality was maintained (am I exaggerating this benefit?)
- when a new connection was received, all threads woke up to activity on
their respective fd copies, and started accepting, I assume from the
same connection queue. This was a disadvantage at low load levels as
threads would often wake and find nothing to do, but as loads got
higher, strace showed that less threads would awake to disappointment.
- this approach was able to handle stress tests from a hardware packet
generator, which showed no dropped or unhandled connections.
One disadvantage I imagined was that the single socket and all of its
duplicates may find themselves attached to one cpu core or hardware
queue on the network adapter, I don't know enough about the core net
internals to say for sure, but as a precaution the dup was done in the
context of the thread that would use the copy.
Just sharing and seeking comments.
next prev parent reply other threads:[~2013-01-25 5:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-22 19:49 [PATCH 0/5]: soreuseport: Bind multiple sockets to the same port Tom Herbert
2013-01-22 20:28 ` David Miller
2013-01-25 5:06 ` Nick Jones [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-01-14 20:00 Tom Herbert
2013-01-14 20:29 ` David Miller
2013-01-14 23:35 ` Vijay Subramanian
2013-01-15 1:33 ` Tom Herbert
2013-01-15 9:34 ` David Laight
2013-01-16 18:22 ` Tom Herbert
2013-01-17 9:53 ` David Laight
2013-01-17 14:27 ` Eric Dumazet
2013-01-21 7:23 ` Li Yu
2013-01-21 7:58 ` Li Yu
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=510212C6.6060303@network-box.com \
--to=nick.jones@network-box.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=netdev@markandruth.co.uk \
--cc=netdev@vger.kernel.org \
--cc=therbert@google.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.