UDP load balancing - 1 new socket for each incoming packet?
arut at nginx.com
Thu Sep 1 08:02:09 UTC 2016
On Thu, Sep 01, 2016 at 02:58:50PM +0800, Gwenole Gendrot wrote:
> I've been using nginx 1.11.3 to test the UDP load balancing feature, using a
> "basic" configuration.
> The functionality is working out of the box, but a new socket will be
> created by the proxy for each packet sent from a client (to the same
> connection). This leads to resource exhaustion under heavy load (even with
> only 1 client / 1 server).
> My question: is it the intended behaviour to open a new socket for each
> incoming packet?
Yes, a new socket is created for an incoming UDP datagram to proxy it
to the upstream server and to proxy the response datagram(s) back to client.
> - if no => is this a bug? some misconfiguration from my part (either in
> nginx or Linux)? has anyone observed this behaviour?
> - if yes => is reusing the socket for the same connection a missing feature
> / future improvement?
Datagrams sent from the same client are not considered as a part of a single
connection. In fact, they can even be received by different nginx workers.
And yes, this is a subject for the future improvement.
> P.S.: my current workaround is to set the proxy timeout to a very low value
> and increase the maximum number of concurrent connections & opened
If you know in advance how many datagrams you are expecting in response to a
single client datagram, you can use the proxy_responses directive to set it.
In this case nginx will close the session (and release the socket) once the
required number of datagrams is sent back to client.
> P.P.S: Logs were empty of warnings & errors. My coonfiguration (nothing
> fancy, pretty much all the system & SW are from a fresh install) as
> Gwenole Gendrot
> 156 1835 3270
More information about the nginx