[CSHARP-3960] Consider changing the default of MaxConnectionLifeTime to infinite Created: 09/Nov/21  Updated: 31/Mar/22

Status: Backlog
Project: C# Driver
Component/s: Connectivity
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Unknown
Reporter: Boris Dogadov Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   
  • Avoid killing and recreating active connections every 30 minutes
  • Follow the CMAP spec for connection management


 Comments   
Comment by Robert Stam [ 10/Nov/21 ]

Fair point that MaxConnectionLifeTime should be added to the CMAP spec.

Comment by Robert Stam [ 10/Nov/21 ]

I doesn't seem like DRIVERS-1198 will help at all with the load balancing issue.

I disagree that we should remove MaxConnectionLifeTime. But given what we have learned about how long lived connections interact badly with load balancing we should reduce the default value to something a lot shorter than 30 minutes.

Comment by Boris Dogadov [ 10/Nov/21 ]

It would be great to have any evidence of the original problem, and maybe gather some data from other drivers as well.
Sounds like load balancers problem would be a common problem among all drivers, in that case it should be addressed by CMAP spec.

While ConnectionSettings.MaxLifeTime might mitigate the problem of possible network instability to some extent, it might not be the ideal approach.
DRIVERS-1198 should address that, maybe it will introduce more adaptive approach, which might perform better.

I think that connection management in this case should align as much as possible with CMAP spec.
I would suggest that as part of DRIVERS-1198 or before, we turn off MaxLifeTime by default and then deprecate it.

Comment by Robert Stam [ 10/Nov/21 ]

While MaxConnectionLifeTime was originally introduced to deal with network environments that don't deal reliably with long lived connections, now that we support mongos behind a load balancer there is an additional reason to keep MaxConnectionLifeTime: load balancers don't balance well when connections are long lived.

Here's an interesting article on how long lived connections interfere with load balancing:

https://www.ateam-oracle.com/post/long-lived-tcp-connections-and-load-balancers

So perhaps we should actually move in the opposite direction, and reduce the default value of MaxConnectionLifeTime from 30 minutes to something like 5 minutes. Figuring out the best new smaller value is tricky.

Generated at Wed Feb 07 21:46:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.