[En-Nut-Discussion] Too many very fast opened / closed TCP connections may let the system run out of memory

Harald Kipp harald.kipp at egnite.de
Sun Jan 12 12:08:42 CET 2014


Hi Ole,

On 10.01.2014 18:59, Ole Reinhardt wrote:
> When creating sockets very fast and directly closing them again, as soon
> as the connection is established may let the Nut/OS device run out of
> memory.

...

> Reason:
> =======
> 
> As soon as the TCP socket is closed, the socket will not be destroyed
> directly, but the TCP statemachine changes the socket state to
> TCPS_TIME_WAIT. This is totally correct.
> 
> See http://tools.ietf.org/html/rfc793

That's what I immediately intended to answer before reading your full
post. :-)


> But we should think about, if there may be any solution to limit the
> memory usage, while still correctly implementing the TCP standard
> requirement.

IMHO, it is generally a bad idea using short lived TCP connections.
Sooner or later this will bring down every machine. What's the actual
need to do so?

A client may reduce his connection rate based on available memory. For
the passive server this is a bit more difficult. So far I throttled the
server in low memory situations by simply adding a NutSleep before
accepting new connections. Of course, this may result in connection rejects.

Regards,

Harald



More information about the En-Nut-Discussion mailing list