I just read about Linux v3.9's SO_REUSEPORT feature and decided to implement it for Dovecot. Would be interesting to know how it works for people :) It's going to be in v2.2.6, which I'm planning on releasing tomorrow. Note especially the warning about the bug:
http://hg.dovecot.org/dovecot-2.2/rev/a991a0547daa
So the idea is that you'd do something like:
service imap-login { inet_listener imap { reuse_port = yes } process_min_avail = 4 # number of CPU cores }
And the load should be distributed more evenly to the processes.
On Mon, 23 Sep 2013 09:50:18 +0300 Timo Sirainen articulated:
I just read about Linux v3.9's SO_REUSEPORT feature and decided to implement it for Dovecot. Would be interesting to know how it works for people :) It's going to be in v2.2.6, which I'm planning on releasing tomorrow. Note especially the warning about the bug:
http://hg.dovecot.org/dovecot-2.2/rev/a991a0547daa
So the idea is that you'd do something like:
service imap-login { inet_listener imap { reuse_port = yes } process_min_avail = 4 # number of CPU cores }
And the load should be distributed more evenly to the processes.
From the link above, "I'm not sure if this makes any difference in BSDs." I can almost guarantee that it will not work with FreeBSD. They are years behind in keeping compatibility with Linux. They are still using the Fedora f10 base, over five years old.
-- Jerry ♔
Disclaimer: off-list followups get on-list replies or get ignored. Please do not ignore the Reply-To header.
On 23.9.2013, at 13.54, Jerry <jerry@seibercom.net> wrote:
From the link above, "I'm not sure if this makes any difference in BSDs." I can almost guarantee that it will not work with FreeBSD. They are years behind in keeping compatibility with Linux. They are still using the Fedora f10 base, over five years old.
This feature originated from BSDs that had it long time ago.
At 2PM +0300 on 23/09/13 you Timo Sirainen wrote:
[SO_REUSEPORT]
This feature originated from BSDs that had it long time ago.
SO_REUSEPORT was introduced in 4.4 BSD, but the new Linux feature which includes load balancing is something rather different. It's a pity the Linux (Google?) people didn't choose a different name for it.
4.4's SO_REUSEPORT just allows multiple (pre-TIME_WAIT) sockets to bind to the same local address:port. It was introduced for the benefit of multicast apps; AFAIK its only significant non-multicast use is in ftpd, which in active mode has to create lots of outgoing sockets originating from the same source address:port. The question of load balancing obviously doesn't apply here, since the connections are initiated by the server.
With a 4.4 implementation, setting SO_REUSEPORT is actively bad for something like Dovecot: while all the sockets will be allowed to bind, connections will only be passed to the first until that is closed, then to the next, and so on. Of the BSDs, DragonFly has implemented the Linux semantics (including a fix for the bug mentioned in your commit message); I believe the others, including OSX, are still using the 4.4 code.
Ben
On 9/24/2013 02:06, Ben Morrow wrote:
At 2PM +0300 on 23/09/13 you Timo Sirainen wrote:
[SO_REUSEPORT]
This feature originated from BSDs that had it long time ago.
SO_REUSEPORT was introduced in 4.4 BSD, but the new Linux feature which includes load balancing is something rather different. It's a pity the Linux (Google?) people didn't choose a different name for it.
4.4's SO_REUSEPORT just allows multiple (pre-TIME_WAIT) sockets to bind to the same local address:port. It was introduced for the benefit of multicast apps; AFAIK its only significant non-multicast use is in ftpd, which in active mode has to create lots of outgoing sockets originating from the same source address:port. The question of load balancing obviously doesn't apply here, since the connections are initiated by the server.
With a 4.4 implementation, setting SO_REUSEPORT is actively bad for something like Dovecot: while all the sockets will be allowed to bind, connections will only be passed to the first until that is closed, then to the next, and so on. Of the BSDs, DragonFly has implemented the Linux semantics (including a fix for the bug mentioned in your commit message); I believe the others, including OSX, are still using the 4.4 code.
Ben
Details of Linux SO_REUSEPORT implementation can be found here: https://lwn.net/Articles/542629/
-- staticsafe O< ascii ribbon campaign - stop html mail - www.asciiribbon.org Please don't top post. It is not logical. Please don't CC me! I'm subscribed to whatever list I just posted on.
participants (4)
-
Ben Morrow
-
Jerry
-
staticsafe
-
Timo Sirainen