Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make TCP keepalive parameters configurable #102

Open
ansd opened this issue Aug 11, 2022 · 0 comments
Open

Make TCP keepalive parameters configurable #102

ansd opened this issue Aug 11, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@ansd
Copy link
Member

ansd commented Aug 11, 2022

TCP keepalive is optional and off by default.

Its purpose is to:

  1. detect dead peers. If peer is not alive, close the socket to save resources.
  2. prevent connection from being closed by firewall or NAT proxy due to inactivity.

A real world use case of 2. got reported in https://rabbitmq.slack.com/archives/C1EDN83PA/p1656489674972399.

Therefore in Osiris, TCP keepalive can be optionally enabled for the stream data replication. Both client and server have to opt in by setting osiris parameter replica_keepalive:

This issue is about whether we should make the TCP keepalive parameters configurable:

  1. Keepalive time is the duration between two keepalive transmissions in idle condition. TCP keepalive period is required to be configurable and by default is set to no less than 2 hours.
  2. Keepalive interval is the duration between two successive keepalive retransmissions, if acknowledgement to the previous keepalive transmission is not received.
  3. Keepalive retry is the number of retransmissions to be carried out before declaring that remote end is not available

Specifically, it may be desirable to decrease 1. Keepalive time to a value lower than 2 hours.

See https://github.com/emqx/emqx/blob/6d5ad97528072e7b9186cb35e2eab7695dd0393a/apps/emqx/src/emqx_connection.erl#L269-L272 for an Erlang example.

Note however:

Code such as these [raw socket option] examples is inherently non-portable, even different versions of the same OS on the same platform can respond differently to this kind of option manipulation. Use with care.

@ansd ansd added the enhancement New feature or request label Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant