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

Enable keep alive on tcp connections via feature #886

Merged
merged 2 commits into from
Jul 17, 2023

Conversation

DoumanAsh
Copy link
Contributor

@DoumanAsh DoumanAsh commented Jul 11, 2023

This enables keep alive on tcp sockets via keep-alive feature

Do you want to have it configurable so that only ConnectionManager would enable it?
There is no harm in enabling it for short living connections as default intervals are quite long

Note that this doesn't really fix anything, but for long living connections it will speed up failure detection

Related to #885

package socket2 v0.5.3 cannot be built because it requires rustc 1.63 or newer, while the currently active rustc version is 1.60.0

Unfortunate sad state of rust networking

Just for reference redis(server) default value for keep-alive is 300 seconds (Ref)

@DoumanAsh DoumanAsh force-pushed the socket2_imp branch 2 times, most recently from f20d756 to 7f51639 Compare July 11, 2023 03:19
@jaymell
Copy link
Contributor

jaymell commented Jul 11, 2023

Thanks for this!

Do you want to have it configurable so that only ConnectionManager would enable it?

Is there any reason to limit it to ConnectionManager? Also, please correct me if I'm wrong, but currently the sync connection would need a similar setup in order to use keep-alives, correct? If so, I think it might be reasonable to feature-gate keep-alives/the socket2 dependency behind a new feature we could enable by default and let the whole lib use it. What do you think?

@DoumanAsh
Copy link
Contributor Author

Is there any reason to limit it to ConnectionManager

It is unclear how user will use regular connection and whether he wants to use keep-alive.
but in general keep-alive itself has impact only on long living connections, so that's why I asked whether you'd prefer to enable it on all connections or only long living one.

Also, please correct me if I'm wrong, but currently the sync connection would need a similar setup in order to use keep-alives, correct

Yes, in similar manner it can be enabled for sync clients.

If you prefer to feature gate the whole keep-alive on all connections, then I'll do it for all connections

@DoumanAsh
Copy link
Contributor Author

I refactored PR to hide socket2 behind keep-alive feature

@DoumanAsh DoumanAsh marked this pull request as ready for review July 11, 2023 05:41
@jaymell
Copy link
Contributor

jaymell commented Jul 11, 2023

If you prefer to feature gate the whole keep-alive on all connections, then I'll do it for all connections

I think it sounds like a good approach!

@DoumanAsh DoumanAsh changed the title Enable keep alive on tcp connections in aio Enable keep alive on tcp connections via feature Jul 11, 2023
@jaymell
Copy link
Contributor

jaymell commented Jul 16, 2023

Sorry for the delay, but one more request: Can we enable the feature by default?

@nihohit
Copy link
Contributor

nihohit commented Jul 16, 2023

not for this PR, in order not to block it, but we should probably also use this in sync connections, not only in async.

@jaymell
Copy link
Contributor

jaymell commented Jul 17, 2023

@nihohit Sorry I'm not sure I follow your last comment.

@jaymell jaymell merged commit 29b4702 into redis-rs:main Jul 17, 2023
10 checks passed
@DoumanAsh DoumanAsh deleted the socket2_imp branch July 21, 2023 01:42
nihohit pushed a commit to amazon-contributing/redis-rs that referenced this pull request Jul 23, 2023
This enables keep alive on tcp sockets via keep-alive feature.
@nihohit nihohit mentioned this pull request Jul 30, 2023
altanozlu pushed a commit to altanozlu/redis-rs that referenced this pull request Aug 16, 2023
This enables keep alive on tcp sockets via keep-alive feature.
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.

None yet

3 participants