ohler55 / agoo

A High Performance HTTP Server for Ruby
MIT License
912 stars 39 forks source link

Unconditional use of `SO_REUSEPORT` #83

Closed norswap closed 4 years ago

norswap commented 4 years ago

agoo makes unconditional use of the socket option SO_REUSEPORT.

As explained here and there, its semantics are different on Linux (load-balancing between multiple servers/threads) and BSDs (the last server to bind gets the new connections).

Both are in fact pretty useful (the second one allows for seamless server restarts), but since they have different use cases, it would be interesting to clarify what was intended. Also the StackOverflow post linked above mentions that recent FreeBSDs have SO_REUSEPORT_LB that behaves like the Linux version.

See discussion at https://github.com/oracle/truffleruby/issues/1592

ohler55 commented 4 years ago

Please take a look at branch 'reuseport' and see it that works for you.

I agree the behaviour is different between macOS and Linux but only because each attempts to handle the issue in different ways. I don't think Agoo should attempt work around the OS default behaviour. Basically Agoo wants to be able to restart in a way that is expected on the OS.

norswap commented 4 years ago

I'm not even using agoo myself, just came accross the issue while working on TruffleRuby and thought I'd point it out.

The explanation checks out, thanks for the answer!