msquic
msquic copied to clipboard
Why is the motivation to always set `SO_REUSEPORT` for servers
https://github.com/microsoft/msquic/blob/5b921c9e187d2c59a43ec285be1a06e99349d1b2/src/platform/datapath_epoll.c#L1173-L1195
My understanding is that this code always set SO_REUSEPORT for a server, and you will not get the address already in use when two servers use the same address, what is the motivation for this? did you consider making it configurable?
We create per-processor sockets to efficiently scale and align with RSS.
Would be nice if applications can configure this behavior
Would be nice if applications can configure this behavior
May I ask why?
Because if two different server applications happen to configure the same address and port, it would be nice to get an error, this is the most expected behavior for a server.
So, you'd prefer to get an error in this case rather than have the performance/scale of using multiple processors on the server side?
I talking about two unrelated application servers configured in the same address port, for example, two HTTP servers handling different applications, in this case, you deserve to get an error yes.
On Windows, the second process would get an error code indicating that the requested listening address is already in use (EADDRINUSE), it would be nice to have consistent behavior across platforms if it can be achieved without significant performance loss.
Any thoughts here @tmds? Basically we need multiple sockets on the same port to load-balance inbound UDP traffic via RPS
You're setting SO_REUSEPORT (on Linux) to distribute UDP packets across multiple receiving sockets.
There is no way to prevent another process (that runs as the same user) from creating additional receiving socket.