Skip to content

Retire HTTP/2 connections at connectionTTL - #2387

Open
hyperxpro wants to merge 2 commits into
mainfrom
feature/http2-connection-ttl
Open

hyperxpro wants to merge 2 commits into
mainfrom
feature/http2-connection-ttl

Conversation

@hyperxpro

Copy link
Copy Markdown
Member

Motivation:

HTTP/2 connections live in ChannelManager's registry, not the channel pool, so connectionTtl never applied to them. Nothing else bounds their age: the registry has no reaper and PING keeps an idle connection alive. A client that sets connectionTtl to follow DNS or load-balancer changes keeps every HTTP/2 connection for good.

Modification:

Arm one task per HTTP/2 connection on its event loop when the pipeline is upgraded, delayed by 90-100% of connectionTtl so connections opened together do not expire together. On expiry the connection is retired: it leaves the registry, gives back its ROUND_ROBIN permit, finishes the streams it holds and the openers queued for a slot, and closes once it has neither. Idle check and stream admission are one CAS on the stream count, so a late request either keeps the connection open or is refused before anything is written. A refused request, or one that finds the retired connection already closed, is sent once more through sendNextRequest without spending maxRequestRetry. No GOAWAY is sent early; Netty's close() sends GOAWAY(NO_ERROR) when the idle connection closes.

Result:

connectionTtl bounds HTTP/2 connections as it does HTTP/1.1 ones. With the default of -1 nothing is added to the pipeline.

Fixes #2370

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support a maximum lifetime for HTTP/2 connections

1 participant