samalba / dockerclient

Docker client library in Go
http://www.docker.com/
Apache License 2.0
320 stars 140 forks source link

Accelerate dead peer detection with user timeout option #202

Closed dongluochen closed 8 years ago

dongluochen commented 8 years ago

Dockerclient are used by other tools like swarm. Swarm manager normally maintains 2-6 established TCP connections with an engine thru HTTP keepalive. When an engine goes offline abruptly, like engine crash, host pause, network failure, these connections remain in Established state. By default swarm manager relies on system dead connection detection mechanism to fail requests. In typical Linux system it's around 13-20 minutes, depending on tcp_retries1, tcp_retries2 and retransmit timeout value. From user perspective, docker CLI hangs.

RFC5482 defines TCP_USER_TIMEOUT so a sender can break the connection faster. While Golang doesn't support this socket option. Linux and Windows have different options to support user timeout.

Signed-off-by: Dong Chen dongluo.chen@docker.com

dongluochen commented 8 years ago

Ping @vieux @abronan.

vieux commented 8 years ago

LGTM

ping @ehazlett

ehazlett commented 8 years ago

LGTM