<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:24:25 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[DRIVERS-1977] Add a default idle timeout for pooled connections to CMAP</title>
                <link>https://jira.mongodb.org/browse/DRIVERS-1977</link>
                <project id="10980" key="DRIVERS">Drivers</project>
                    <description>&lt;div class=&quot;panel&quot; style=&quot;background-color: #fafbfc;border-width: 1px;&quot;&gt;&lt;div class=&quot;panelContent&quot; style=&quot;background-color: #fafbfc;&quot;&gt;
&lt;h3&gt;&lt;a name=&quot;Summary&quot;&gt;&lt;/a&gt;&lt;b&gt;Summary&lt;/b&gt;&lt;/h3&gt;

&lt;p&gt;By 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.&lt;/p&gt;

&lt;p&gt;We should amend the &lt;a href=&quot;https://github.com/mongodb/specifications/blob/e827caab1af16310ce1d6f4dce6fd97e903fc75e/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;CMAP specification&lt;/a&gt; to set a default &lt;a href=&quot;https://github.com/mongodb/specifications/blob/e827caab1af16310ce1d6f4dce6fd97e903fc75e/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst#connection-pool-options-1&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;maxIdleTimeMS&lt;/a&gt; of &lt;tt&gt;1800000&lt;/tt&gt; (30 minutes). To prevent connection churn when maintaining &lt;tt&gt;minPoolSize&lt;/tt&gt;, we should also amend the definition of &lt;a href=&quot;https://github.com/mongodb/specifications/blob/5964c134a85707dcfa3c54b7f9f88d3451f4a175/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst#connection-1&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Idle&lt;/a&gt; to the following:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;b&gt;Idle&lt;/b&gt;: The Connection is currently &quot;available&quot; (as defined below), has been &quot;available&quot; for longer than &lt;b&gt;maxIdleTimeMS&lt;/b&gt;, and the number of total connections in the pool is greater than &lt;b&gt;minPoolSize&lt;/b&gt;.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;References for picking a reasonable default idle timeout:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;The Go HTTP client &lt;a href=&quot;https://pkg.go.dev/net/http#RoundTripper&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;&quot;net/http&quot;.DefaultTransport&lt;/tt&gt;&lt;/a&gt; uses a default idle connection timeout of 90 seconds.&lt;/li&gt;
	&lt;li&gt;The Go SQL client &lt;a href=&quot;https://pkg.go.dev/database/sql#DB.SetMaxIdleConns&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;&quot;database/sql&quot;.DB&lt;/tt&gt;&lt;/a&gt; has no default idle connection timeout, but uses a default limit of 2 idle connections.&lt;/li&gt;
	&lt;li&gt;The OpenJDK 11 HttpClient &lt;a href=&quot;https://github.com/AdoptOpenJDK/openjdk-jdk11/blob/19fb8f93c59dfd791f62d41f332db9e306bc1422/src/java.net.http/share/classes/jdk/internal/net/http/ConnectionPool.java#L54-L55&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;ConnectionPool&lt;/a&gt; uses a default idle connection timeout of 20 minutes.&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://docs.mongodb.com/manual/reference/parameters/#mongodb-parameter-param.cursorTimeoutMillis&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;MongoDB cursors&lt;/a&gt; have a default server-side timeout of 10 minutes.&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://docs.mongodb.com/manual/reference/command/startSession/#output&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;MongoDB sessions&lt;/a&gt; have a default server-side timeout of 30 minutes.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;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.&lt;/p&gt;

&lt;h3&gt;&lt;a name=&quot;Motivation&quot;&gt;&lt;/a&gt;&lt;b&gt;Motivation&lt;/b&gt;&lt;/h3&gt;
&lt;h4&gt;&lt;a name=&quot;Whoistheaffectedenduser%3F&quot;&gt;&lt;/a&gt;Who is the affected end user?&lt;/h4&gt;

&lt;p&gt;Anyone who uses a driver with the default &lt;tt&gt;maxIdleTimeMS&lt;/tt&gt; setting.&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;Howdoesthisaffecttheenduser%3F&quot;&gt;&lt;/a&gt;How does this affect the end user?&lt;/h4&gt;

&lt;p&gt;The driver may hold effectively unused TCP connection resources indefinitely.&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;Howlikelyisitthatthisproblemorusecasewilloccur%3F&quot;&gt;&lt;/a&gt;How likely is it that this problem or use case will occur?&lt;/h4&gt;

&lt;p&gt;The problem will occur any time a customer uses the default &lt;tt&gt;maxIdleTimeMS&lt;/tt&gt; in an application that has variable demand for connections.&lt;/p&gt;

&lt;p&gt;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 &lt;tt&gt;maxIdleTimeMS&lt;/tt&gt;, it will never close those now-idle connections.&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;Iftheproblemdoesoccur%2Cwhataretheconsequencesandhowseverearethey%3F&quot;&gt;&lt;/a&gt;If the problem does occur, what are the consequences and how severe are they?&lt;/h4&gt;

&lt;p&gt;There are a few consequences:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Increased memory and network resource usage (client-side and server-side TCP handles, TCP keepalive pings for idle connections, maybe additional server-side resources?).&lt;/li&gt;
	&lt;li&gt;Reduced buffer between the number of open connections and the maximum client-side and server-side connection limits.
	&lt;ul&gt;
		&lt;li&gt;In practice, this is probably more significant for server-side connection limits, especially for low-tier Atlas clusters which tend to have a low per-node connection limit.&lt;br/&gt;
 For example, consider a customer who runs 10 instances of a web application connected to an Atlas M10 3-node replicaset (max 1,500 connections per node). Under normal request throughput, each web application instance opens 15 connections to the primary (150 connections total). The buffer between the current and maximum connection limit is 1,350 connections. A large spike in request throughput causes the driver on each web application instance to create the default maximum of 100 connections to the primary (1,000 connections total). The buffer between the current and maximum connection limit is now only 500 connections and will not recover (using the default &lt;tt&gt;maxIdleTimeMS&lt;/tt&gt;) until the web application instances are restarted.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;


&lt;h4&gt;&lt;a name=&quot;Isthisissueurgent%3F&quot;&gt;&lt;/a&gt;Is this issue urgent?&lt;/h4&gt;

&lt;p&gt;No.&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;Isthisticketrequiredbyadownstreamteam%3F&quot;&gt;&lt;/a&gt;Is this ticket required by a downstream team?&lt;/h4&gt;

&lt;p&gt;No.&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;Isthisticketonlyfortests%3F&quot;&gt;&lt;/a&gt;Is this ticket only for tests?&lt;/h4&gt;

&lt;p&gt;No.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
        <key id="1917803">DRIVERS-1977</key>
            <summary>Add a default idle timeout for pooled connections to CMAP</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="10300" iconUrl="https://jira.mongodb.org/images/icons/priorities/medium.svg">Unknown</priority>
                        <status id="10038" iconUrl="https://jira.mongodb.org/images/icons/subtask.gif" description="">Backlog</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="matt.dale@mongodb.com">Matt Dale</reporter>
                        <labels>
                            <label>faas</label>
                    </labels>
                <created>Thu, 4 Nov 2021 00:33:56 +0000</created>
                <updated>Mon, 10 Apr 2023 18:38:40 +0000</updated>
                                                                <component>CMAP</component>
                    <component>FaaS</component>
                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                    <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                                        </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="1308136">GODRIVER-1560</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="1887543">GODRIVER-2168</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                            <customfield id="customfield_13552" key="com.go2group.jira.plugin.crm:crm_generic_field">
                        <customfieldname>Case</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[[5006R00001onH5XQAU]]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10951" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Driver Changes</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10748"><![CDATA[Needed]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hzsiyn:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        </customfields>
    </item>
</channel>
</rss>