[DRIVERS-1977] Add a default idle timeout for pooled connections to CMAP Created: 04/Nov/21 Updated: 10/Apr/23 |
|
| Status: | Backlog |
| Project: | Drivers |
| Component/s: | CMAP, FaaS |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Unknown |
| Reporter: | Matt Dale | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | faas | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Driver Changes: | Needed | ||||||||||||
| Case: | (copied to CRM) | ||||||||||||
| Description |
SummaryBy default, drivers currently do not limit connection idle time for pooled connections. Drivers using the default configuration will never close idle connections, even if they are idle for long periods of time. For applications with variable demand for connections, that means driver connection pools may grow as demand increases but never shrink when demand reduces. As a result, client-side and server-side TCP connection resources are never released, even when they are effectively unused. We should amend the CMAP specification to set a default maxIdleTimeMS of 1800000 (30 minutes). To prevent connection churn when maintaining minPoolSize, we should also amend the definition of Idle to the following:
References for picking a reasonable default idle timeout:
Note that creating a new MongoDB connection is typically more expensive than creating a new HTTP connection, so the risk of closing connections too eagerly is higher. We choose a default idle timeout of 30 minutes because it is is equal or greater to all of the reference network client timeouts and server-side state timeouts. MotivationWho is the affected end user?Anyone who uses a driver with the default maxIdleTimeMS setting. How does this affect the end user?The driver may hold effectively unused TCP connection resources indefinitely. How likely is it that this problem or use case will occur?The problem will occur any time a customer uses the default maxIdleTimeMS in an application that has variable demand for connections. For example, if a customer runs a web service that experiences spikes in request throughput, the driver may create new connections to handle the corresponding increase in operation throughput. When the request throughput returns to normal, some driver connections may remain idle for long periods of time (depending on the frequency of request throughput spikes). If the driver is configured with the default maxIdleTimeMS, it will never close those now-idle connections. If the problem does occur, what are the consequences and how severe are they?There are a few consequences:
Is this issue urgent?No. Is this ticket required by a downstream team?No. Is this ticket only for tests?No. |