Skip to content

httpd should close connections that have been idle for a long time #3130

@nyh

Description

@nyh

#3129 reports that: "What we are seeing with AWS load balancers is that they silently drop idle connection state after a while. This is transparent to the server, the connections just stays established forever.".

For this and many other reasons (clients disappearing, rebooting, etc.) our http server might end up with a very large number of idle connection, supposedly kept alive for the client to reuse them but the client will never do and these connections will never get closed. This is bad, and even dangerous.

In #3129, it was suggested to use kernel-level TCP keepalive (with low settings) to solve this problem. But #3129 did not turn this feature on by default - it just provided a mechanism. I'm suggesting here that perhaps we should turn this feature on by default.

Alternatively, instead of using TCP keepalive, we could do something even simpler in user-space - we could automatically close any idle connection which is older than some time limit - not even checking if the client is still alive. For example, Apache HTTPd has KeepAliveTimeout https://httpd.apache.org/docs/2.4/mod/core.html#keepalivetimeout - which defaults to just 5 seconds (!). Nginx has keepalive_timeout https://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout which defaults to 75 seconds. Every other HTTP server I looked at seems to have such a timeout, and its default configuration is usually just a few seconds. I don't know if Seastar's default should be so low, but infinity is too high :-)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions