{"id":181,"date":"2007-06-02T14:44:04","date_gmt":"2007-06-02T21:44:04","guid":{"rendered":"http:\/\/kennyw.com\/indigo\/181"},"modified":"2007-06-02T14:44:04","modified_gmt":"2007-06-02T21:44:04","slug":"more-details-on-maxconnections","status":"publish","type":"post","link":"https:\/\/kennyw.com\/?p=181","title":{"rendered":"More details on MaxConnections"},"content":{"rendered":"<p>Here are some more &#8220;under the hood&#8221; details in response to the following question:<\/p>\n<blockquote><p>How is one supposed to interpret the NetTcpBinding.MaxConnections property on the client? My assumption has been that setting this property at the client only allows this number of concurrent connections, and further connection attempts will be queued until an existing connection is released. <\/p><\/blockquote>\n<p>MaxConnections for TCP is not a hard and fast limit, but rather a knob on the connections that we will <em>cache<\/em> in our <a href=\"http:\/\/kennyw.com\/indigo\/173\">connection pool<\/a>.  That is, if you set MaxConnections=2, you can still open 4 client channels on the same factory simultaneously. However, when you close all of these channels, we will only keep two of these connections around (subject to IdleTimeout of course) for future channel usage.  This helps performance in cases where you are creating and disposing client channels. This knob will also apply to the equivalent usage on the server-side as well (that is, when a server-side channel is closed, if we have less than MaxConnections in our server-side pool we will initiate I\/O to look for another new client channel).<\/p>\n<p>The reason that we don&#8217;t have a hard and fast limit on your connection usage is that you already can control the connection usage through your usage of the WCF objects. That is, if you don&#8217;t want to use more than two connections, don&#8217;t create more than two client channels \ud83d\ude42 Any additional knobs at the lower layer would only impede debuggability and predictability.<\/p>\n<p>Note that MaxConnections applies <em>across<\/em> channels.  When sending messages over a single channel, you can only send out one message at a time. That is, your second Send() call will not be initiated until your first Send() completes.  In this manner, our TCP binding can guarantee in-order delivery.  Also, practically speaking there would be a significant amount of complexity (and overall a negative performance hit) if we allowed interleaving of data from multiple messages, as each &#8220;chunk&#8221; would need to be annotated with a scatter\/gather message marker.<\/p>\n<p>Lastly, all of the above comments apply to TransferMode.Buffered (the default).  When using Streaming mode, we &#8220;check out&#8221; a connection for each in-progress send (and not per-channel). So all the above statements will apply to simultaneous sends rather than simultaneous channels. Streaming TCP is a datagram (not a session-ful) channel, and so simultaneous sends are supported since each send will use a separate TCP connection.  This is more similar to HTTP&#8217;s usage of TCP connections (where each in-flight request-response pair is using a separate TCP connection).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here are some more &#8220;under the hood&#8221; details in response to the following question: How is one supposed to interpret the NetTcpBinding.MaxConnections property on the client? My assumption has been that setting this property at the client only allows this number of concurrent connections, and further connection attempts will be queued until an existing connection [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-181","post","type-post","status-publish","format-standard","hentry","category-indigo"],"_links":{"self":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts\/181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=181"}],"version-history":[{"count":0,"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts\/181\/revisions"}],"wp:attachment":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}