blob: a3230335305e339a163d7acaa6d9218c8552c66c [file] [log] [blame]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<!-- Always force latest IE rendering engine or request Chrome Frame -->
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,300italic,400italic,400,600' rel='stylesheet' type='text/css'>
<!-- Use title if it's in the page YAML frontmatter -->
<title>
Pool Configuration Example and Settings |
Geode Native .NET Docs
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/stylesheets/all.css" rel="stylesheet" media="screen, print" />
<link href="/stylesheets/print.css" rel="stylesheet" media="print" />
<link href='/images/favicon.ico' rel='shortcut icon'>
<script src="/javascripts/all.js"></script>
</head>
<body class="docs docs_geode-native docs_geode-native_dotnet docs_geode-native_dotnet_113 docs_geode-native_dotnet_113_connection-pools docs_geode-native_dotnet_113_connection-pools_configuring-pools-attributes-example has-subnav">
<div class="viewport">
<div class='wrap'>
<script type="text/javascript">
document.domain = "apache.org";
</script>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<header class="header header-layout">
<h1 class="logo">
<a href="/">
<img src="/images/Apache_Geode_logo_symbol_white.png" style="width:30px;">
Apache Geode Native .NET Documentation
</a>
</h1>
<div class="header-links js-bar-links">
<div class="btn-menu" data-behavior="MenuMobile"></div>
<div class="header-item"><a href="http://geode.apache.org">Back to Product Page</a></div>
<div class="header-item">
<a href="http://geode.apache.org/community" target="_blank">Community</a>
</div>
</div>
</header>
<div class="container">
<!--googleoff: index-->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div id="sub-nav" class="js-sidenav nav-container" role="navigation">
<a class="sidenav-title" data-behavior="SubMenuMobile">Doc Index</a>
<div class="nav-content">
<ul>
<li>
<a href="/docs/geode-native/dotnet/113/about-client-users-guide.html">Apache Geode Native Documentation</a>
</li>
<li class="has_submenu">
<a href="/docs/geode-native/dotnet/113/getting-started/getting-started-nc-client.html">Getting Started with the Native Library</a>
<ul>
<li>
<a href="/docs/geode-native/dotnet/113/getting-started/getting-started-nc-client.html#set_up_dev_environment">Set Up Your Development Environment</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/getting-started/getting-started-nc-client.html#establish_cluster_access">Establish Access to a Geode Cluster</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/getting-started/getting-started-nc-client.html#app_dev_walkthroughs">Application Development Walkthroughs</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/getting-started/getting-started-nc-client.html#programming_examples">Programming Examples</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/getting-started/put-get-example.html">Put/Get/Remove Examples</a>
</li>
</ul>
</li>
<li class="has_submenu">
<a href="/docs/geode-native/dotnet/113/configuring/configuration.html">Configuring a Client Application</a>
<ul>
<li>
<a href="/docs/geode-native/dotnet/113/configuring/system-level-configuration.html">System Level Configuration</a>
</li>
</ul>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/configuring/config-client-cache.html">Configuring the Client Cache</a>
</li>
<li class="has_submenu">
<a href="/docs/geode-native/dotnet/113/regions/regions.html">Configuring Regions</a>
<ul>
<li>
<a href="/docs/geode-native/dotnet/113/regions/registering-interest-for-entries.html">Registering Interest for Entries</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/regions/region-attributes.html">Region Attributes</a>
</li>
</ul>
</li>
<li class="has_submenu">
<a href="/docs/geode-native/dotnet/113/connection-pools/configuring-pools.html">Configuring Pools</a>
<ul>
<li>
<a href="/docs/geode-native/dotnet/113/connection-pools/client-pool-api.html">Native Client Pool API</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/connection-pools/configuring-pools-attributes-example.html">Pool Configuration Example and Settings</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/connection-pools/subscription-properties.html">Subscription Properties</a>
</li>
</ul>
</li>
<li class="has_submenu">
<a href="/docs/geode-native/dotnet/113/serialization/data-serialization.html">Serializing Data</a>
<ul>
<li class="has_submenu">
<a href="/docs/geode-native/dotnet/113/serialization/dotnet-serialization/dotnet-pdx-serialization.html">Geode PDX Serialization</a>
<ul>
<li>
<a href="/docs/geode-native/dotnet/113/serialization/dotnet-serialization/dotnet-pdx-autoserializer.html">Using the Geode PDX Autoserializer</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/serialization/dotnet-serialization/serialize-using-ipdxserializable.html">Using the IPdxSerializable Interface</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/serialization/dotnet-serialization/pdx-serializable-examples.html">IPdxSerializable Example</a>
</li>
</ul>
</li>
</ul>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/remote-queries.html">Remote Queries</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/continuous-queries.html">Continuous Queries</a>
</li>
<li class="has_submenu">
<a href="/docs/geode-native/dotnet/113/security/security.html">Security: Authentication and Encryption</a>
<ul>
<li>
<a href="/docs/geode-native/dotnet/113/security/authentication.html">Authentication</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/security/sslclientserver.html">TLS/SSL Client-Server Communication Encryption</a>
</li>
</ul>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/function-execution.html">Function Execution</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/transactions.html">Transactions</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/configuring/sysprops.html">System Properties</a>
</li>
<li>
<a href="/docs/geode-native/dotnet/113/client-cache-ref.html">Client Cache XML Reference</a>
</li>
</ul>
</div>
</div>
<!--googleon: index-->
<main class="content content-layout" id="js-content" role="main">
<a id="top"></a>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<span style="font-weight:200;font-size:31px;" style="float:left;">
<img src="/images/Apache_Geode_logo_symbol.png" style="height:26px;">
Apache Geode Native .NET
</span>
<span class="local-header version-info" style="float:right;">
<a href="https://cwiki.apache.org/confluence/display/GEODE/Release+Notes">CHANGELOG</a>
</span>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<h1 class="title-container" >
Pool Configuration Example and Settings
</h1>
<div id="js-quick-links" >
</div>
<div class="to-top" id="js-to-top">
<a href="#top" title="back to top"></a>
</div>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<p>Connection pools require standard client/server distributed system and cache configuration settings. You must also configure settings for the locator, server, and pool elements.</p>
<ul>
<li> Locator. Host and port where a server locator is listening.</li>
<li> Server. Host and port where a server is listening.</li>
<li> Pool. Client/server connection pool.</li>
</ul>
<p>This page shows examples of creating a pool configuration programmatically using C# code, and declaratively using XML.</p>
<h2 id="programmatic-pool-configuration">Programmatic Pool Configuration</h2>
<p>This example shows a programmatic pool configuration. For a list of the attributes you can configure, see <code>PoolFactory</code> in the API docs.</p>
<pre class="highlight csharp"><code><span class="n">cache</span><span class="p">.</span><span class="nf">GetPoolManager</span><span class="p">()</span>
<span class="p">.</span><span class="nf">CreateFactory</span><span class="p">()</span>
<span class="p">.</span><span class="nf">AddLocator</span><span class="p">(</span><span class="s">"localhost"</span><span class="p">,</span> <span class="m">34756</span><span class="p">)</span>
<span class="p">.</span><span class="nf">SetFreeConnectionTimeout</span><span class="p">(</span><span class="k">new</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="nf">FromMilliseconds</span><span class="p">(</span><span class="m">12345</span><span class="p">))</span>
<span class="p">.</span><span class="nf">SetIdleTimeout</span><span class="p">(</span><span class="k">new</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="nf">FromMilliseconds</span><span class="p">(</span><span class="m">5555</span><span class="p">))</span>
<span class="p">.</span><span class="nf">SetLoadConditioningInterval</span><span class="p">(</span><span class="k">new</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="nf">FromMilliseconds</span><span class="p">(</span><span class="m">23456</span><span class="p">))</span>
<span class="p">.</span><span class="nf">SetMaxConnections</span><span class="p">(</span><span class="m">7</span><span class="p">)</span>
<span class="p">.</span><span class="nf">SetMinConnections</span><span class="p">(</span><span class="m">3</span><span class="p">)</span>
<span class="p">.</span><span class="nf">SetPingInterval</span><span class="p">(</span><span class="k">new</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="nf">FromMilliseconds</span><span class="p">(</span><span class="m">12345</span><span class="p">))</span>
<span class="p">.</span><span class="nf">SetReadTimeout</span><span class="p">(</span><span class="k">new</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="nf">FromMilliseconds</span><span class="p">(</span><span class="m">23456</span><span class="p">))</span>
<span class="p">.</span><span class="nf">SetRetryAttempts</span><span class="p">(</span><span class="m">3</span><span class="p">)</span>
<span class="p">.</span><span class="nf">SetServerGroup</span><span class="p">(</span><span class="s">"ServerGroup1"</span><span class="p">)</span>
<span class="p">.</span><span class="nf">SetSocketBufferSize</span><span class="p">(</span><span class="m">32768</span><span class="p">)</span>
<span class="p">.</span><span class="nf">SetStatisticInterval</span><span class="p">(</span><span class="k">new</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="nf">FromMilliseconds</span><span class="p">(</span><span class="m">10123</span><span class="p">))</span>
<span class="p">.</span><span class="nf">SetSubscriptionAckInterval</span><span class="p">(</span><span class="k">new</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="nf">FromMilliseconds</span><span class="p">(</span><span class="m">567</span><span class="p">))</span>
<span class="p">.</span><span class="nf">SetSubscriptionEnabled</span><span class="p">(</span><span class="k">true</span><span class="p">)</span>
<span class="p">.</span><span class="nf">SetSubscriptionMessageTrackingTimeout</span><span class="p">(</span><span class="k">new</span> <span class="n">TimeSpan</span><span class="p">.</span><span class="nf">FromMilliseconds</span><span class="p">(</span><span class="m">900123</span><span class="p">))</span>
<span class="p">.</span><span class="nf">SetSubscriptionRedundancy</span><span class="p">(</span><span class="m">0</span><span class="p">)</span>
<span class="p">.</span><span class="nf">SetThreadLocalConnections</span><span class="p">(</span><span class="k">true</span><span class="p">)</span>
<span class="p">.</span><span class="nf">Create</span><span class="p">(</span><span class="s">"test_pool_1"</span><span class="p">);</span>
</code></pre>
<h2 id="declarative-(file-based)-pool-configuration">Declarative (File-based) Pool Configuration</h2>
<p>This example shows a file-based pool configuration using an XML configuration file. Following the example is a table that describes the XML pool attributes you can configure.</p>
<p><strong>Note:</strong>
You create an instance of <code>PoolFactory</code> through <code>PoolManager</code>.</p>
<pre class="highlight plaintext"><code>&lt;pool free-connection-timeout="12345" idle-timeout="5555"
load-conditioning-interval="23456"
max-connections="7" min-connections="3"
name="test_pool_1" ping-interval="12345"
read-timeout="23456" retry-attempts="3" server-group="ServerGroup1"
socket-buffer-size="32768" statistic-interval="10123"
subscription-ack-interval="567" subscription-enabled="true"
subscription-message-tracking-timeout="900123"
subscription-redundancy="0" thread-local-connections="true"&gt;
&lt;locator host="localhost" port="34756"/&gt;
&lt;/pool&gt;
</code></pre>
<h2 id="pool-attributes"><a id="configuring-pools__section_E7AA69F3BB6C4FEA8094E2BC5278A349" class="no-quick-link"></a>Pool Attributes</h2>
<table>
<colgroup>
<col width="25%" />
<col width="50%" />
<col width="25%" />
</colgroup>
<thead>
<tr class="header">
<th>Attribute Name</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><code class="ph codeph">free-connection-timeout</code></td>
<td><p>Number of milliseconds (ms) that the client waits for a free connection if <code class="ph codeph"> max-connections</code> limit is configured and all connections are in use.</p></td>
<td><p>10000 ms</p></td>
</tr>
<tr class="even">
<td><p><code class="ph codeph">idle-timeout</code></p></td>
<td><p>Number of milliseconds to wait for a connection to become idle for load balancing</p></td>
<td><p>5000 ms</p></td>
</tr>
<tr class="odd">
<td><code class="ph codeph">load-conditioning-interval</code></td>
<td><p>Interval in which the pool checks to see if a connection to a specific server should be moved to a different server to improve the load balance.</p></td>
<td><p>300000 ms (5 minutes)</p></td>
</tr>
<tr class="even">
<td><code class="ph codeph">max-connections</code></td>
<td><p>Maximum number of connections that the pool can create. If all connections are in use, an operation requiring a client-to server-connection is blocked until a connection is available or the <code class="ph codeph"> free-connection-timeout</code> is reached. If set to -1, there is no maximum. The setting must indicate a cap greater than <code class="ph codeph"> min-connections</code>.</p>
<div class="note note">
<b>Note:</b>
<p>If you use this setting to cap your pool connections, disable the pool attribute <code class="ph codeph"> pr-single-hop-enabled</code>. Leaving single hop enabled can increase thrashing and lower performance.</p>
</div></td>
<td><p>-1</p></td>
</tr>
<tr class="odd">
<td><p><code class="ph codeph">min-connections</code></p></td>
<td><p>Number of connections that must be created initially.</p></td>
<td><p>5</p></td>
</tr>
<tr class="even">
<td><p><code class="ph codeph">name</code></p></td>
<td><p>Pool name.</p></td>
<td><p></p></td>
</tr>
<tr class="odd">
<td><p><code class="ph codeph">ping-interval</code></p></td>
<td><p>Interval between pinging the server to show the client is alive, set in milliseconds. Pings are only sent when the <code class="ph codeph">ping-interval</code> elapses between normal client messages. This must be set lower than the server’s <code class="ph codeph">maximum-time-between-pings</code>.</p></td>
<td><p>10000 ms</p></td>
</tr>
<tr class="even">
<td><p><code class="ph codeph">pr-single-hop-enabled</code></p></td>
<td><p>Setting used for single-hop access to partitioned region data in the servers for some data operations. See <a href="../client-cache-ref.html#partition-resolver-ref">PartitionResolver</a>. See note in <code class="ph codeph">thread-local-connections</code> below.</p></td>
<td><p>True</p></td>
</tr>
<tr class="odd">
<td><p><code class="ph codeph">read-timeout</code></p></td>
<td><p>Number of milliseconds to wait for a response from a server before the connection times out.</p></td>
<td><p>10000</p></td>
</tr>
<tr class="even">
<td><p><code class="ph codeph">retry-attempts</code></p></td>
<td><p>Number of times to retry an operation after a time-out or exception for high availability. If set to -1, the pool tries every available server once until it succeeds or has tried all servers.</p></td>
<td><p>-1</p></td>
</tr>
<tr class="odd">
<td><p><code class="ph codeph">server-group</code></p></td>
<td><p>Server group from which to select connections. If not specified, the global group of all connected servers is used.</p></td>
<td><p>empty</p></td>
</tr>
<tr class="even">
<td><p><code class="ph codeph">socket-buffer-size</code></p></td>
<td><p>Size of the socket buffer, in bytes, on each connection established.</p></td>
<td><p>32768</p></td>
</tr>
<tr class="odd">
<td><p><code class="ph codeph">statistic-interval</code></p></td>
<td><p>Default frequency, in milliseconds, with which the client statistics are sent to the server. A value of <code class="ph codeph">-1</code> indicates that the statistics are not sent to the server.</p></td>
<td><p>-1</p></td>
</tr>
<tr class="even">
<td><p><code class="ph codeph">subscription-ack-interval</code></p></td>
<td><p>Number of milliseconds to wait before sending an acknowledgment to the server about events received from the subscriptions.</p></td>
<td><p>100</p></td>
</tr>
<tr class="odd">
<td><p><code class="ph codeph">subscription-enabled</code></p></td>
<td><p>Whether to establish a server to client subscription.</p></td>
<td><p>False</p></td>
</tr>
<tr class="even">
<td><p><code class="ph codeph">subscription-message-tracking-timeout</code></p></td>
<td><p>Number of milliseconds for which messages sent from a server to a client are tracked. The tracking is done to minimize duplicate events.</p></td>
<td><p>90000</p></td>
</tr>
<tr class="odd">
<td><p><code class="ph codeph">subscription-redundancy</code></p></td>
<td><p>Redundancy for servers that contain subscriptions established by the client. A value of <code class="ph codeph">-1</code> causes all available servers in the specified group to be made redundant.</p></td>
<td><p>0</p></td>
</tr>
<tr class="even">
<td><p><code class="ph codeph">thread-local-connections</code></p></td>
<td><p>Whether the connections must have affinity to the thread that last used them.</p>
<div class="note note">
<b>Note:</b>
<p>To set this to <code class="ph codeph">true</code>, also set <code class="ph codeph">pr-single-hop-enabled</code> to <code class="ph codeph">false</code>. A <code class="ph codeph">true</code> value in <code class="ph codeph">pr-single-hop-enabled</code> automatically assigns a <code class="ph codeph">false</code> value to <code class="ph codeph">thread-local-connections</code>&hellip;</p>
</div></td>
<td><p>False</p></td>
</tr>
<tr class="odd">
<td><code class="ph codeph">update-locator-list-interval</code></td>
<td>An integer number of milliseconds defining the interval between locator list updates. If the value is less than or equal to 0, the update will be disabled.</td>
<td>5000</td>
</tr>
</tbody>
</table>
</main>
</div>
</div>
</div>
<div id="scrim"></div>
<div class="container">
<footer class="site-footer-links">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div class="copyright">
<a href='/'>Apache Geode Documentation</a>
&copy; 2020 <a href='http://www.apache.org/'>The Apache Software Foundation</a>.
</div>
<div class="support">
Need help? <a href="http://geode.apache.org/community" target="_blank">Visit the Community</a>
</div>
</footer>
</div><!--end of container-->
</body>
</html>