-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Linux 3.9 added the socket option SO_REUSEPORT
which is also available in freebsd. Maybe we could have an option to use it or if present, use it. One advantage I see in it is that it would improve the way connections are distributed across processes.
See the post on LWN for more information:
https://lwn.net/Articles/542629/
In which we can read the difference with using SO_REUSEADDR as we do now:
The problem with this technique, as Tom pointed out, is that when multiple threads are waiting in the accept() call, wake-ups are not fair, so that, under high load, incoming connections may be distributed across threads in a very unbalanced fashion. At Google, they have seen a factor-of-three difference between the thread accepting the most connections and the thread accepting the fewest connections; that sort of imbalance can lead to underutilization of CPU cores. By contrast, the SO_REUSEPORT implementation distributes connections evenly across all of the threads (or processes) that are blocked in accept() on the same port.
Thoughts?