JezK
Edit File: tdspool.html
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>TDS Connection Pooling</title><link rel="stylesheet" type="text/css" href="userguide.css" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="home" href="index.html" title="FreeTDS User Guide" /><link rel="up" href="configs.html" title="Chapter 5. Advanced Configurations" /><link rel="prev" href="appendmode.html" title="Appending Dump Files" /><link rel="next" href="stunnel.html" title="stunnel HOWTO" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">TDS Connection Pooling</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="appendmode.html">Prev</a> </td><th width="60%" align="center">Chapter 5. Advanced Configurations</th><td width="20%" align="right"> <a accesskey="n" href="stunnel.html">Next</a></td></tr></table><hr /></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="tdspool"></a>TDS Connection Pooling</h2></div></div></div><p>The Connection Pooling server swims in the <code class="filename">src/pool</code> directory.</p><p>The <span class="productname">FreeTDS</span> connection pool is a server process; it emulates a <span class="productname">SQL Server</span>. Any program that can attach to a real <span class="productname">SQL Server</span> may instead elect to attach to the pool server. The pool in turn connects to the <span class="productname">SQL Server</span> and database you specify, and attempts to share these connections. See the <code class="filename">src/pool/README</code> for a more detailed description of its inner workings.</p><p>To configure the pool server, first make sure <span class="productname">FreeTDS</span> has a working entry for the real <span class="productname">SQL Server</span> by connecting to it with <span class="application">SQSH</span> or another program.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.gif" /></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The <span class="productname">FreeTDS</span> connection pool currently does not supports <acronym class="acronym">TDS</acronym> version 5.0 (Sybase) and encrypted connections. <span class="emphasis"><em>This restriction applies to both the client-to-pool and pool-to-server connections!</em></span> </p></td></tr></table></div><p>After <span class="productname">FreeTDS</span> has been installed, you will find an executable named <span class="command"><strong>tdspool</strong></span> in the <code class="filename">/usr/local/bin</code> directory (or whatever directory was specified with the <span class="command"><strong>configure</strong></span> <code class="option">--with-prefix flag</code> option).</p><p>Edit <code class="filename">pool.conf</code> in the <span class="productname">FreeTDS</span>'s <code class="filename">etc</code> directory. The <code class="filename">pool.conf</code> file is formatted like <code class="filename">freetds.conf</code>, with a section name in brackets and options for each section in key/value pairs.</p><p>Just as in <code class="filename">freetds.conf</code> there are two types of sections, a <code class="literal">[global]</code> section whose options affect all pools, and a section with the name of the pool for pool-specific options. The following options are supported and may appear in either section.</p><div class="table"><a id="tab.pool.conf"></a><p class="title"><strong>Table 5.1. pool.conf settings</strong></p><div class="table-contents"><table class="table" summary="pool.conf settings" border="1"><colgroup><col /><col /><col /><col /></colgroup><thead><tr><th>Name</th><th>Possible Values</th><th>Default</th><th>Meaning</th></tr></thead><tbody><tr><td>user</td><td>Any valid user</td><td>none</td><td>The username used to connect to the pool server.</td></tr><tr><td>password</td><td>Any</td><td>none</td><td>The password of the user at the pool server.</td></tr><tr><td>server user</td><td>Any valid user</td><td>user field</td><td>The username used to connect to the servername.</td></tr><tr><td>server password</td><td>Any</td><td>password field</td><td>The password of the user at the servername.</td></tr><tr><td>server</td><td>Any entry in the freetds.conf file</td><td>none</td><td>The alias from the freetds.conf file representing the servername that will be connected to.</td></tr><tr><td>database</td><td>Any valid database</td><td>User's default database</td><td>The database on the servername to use.</td></tr><tr><td>port</td><td>Any TCP port</td><td>none</td><td>Port on which tdspool will listen.</td></tr><tr><td>min pool conn</td><td>0 or more</td><td>none</td><td>Minimum number of open connections to maintain to the servername. 0 will cause pool server to not open any initial connection.</td></tr><tr><td>max pool conn</td><td>1 or more</td><td>none</td><td>Maximum number of open connections to open against the servername.</td></tr><tr><td>max member age</td><td>0 (no limit) or a number of seconds</td><td>0</td><td>Maximum age of idle members before connection is closed.</td></tr></tbody></table></div></div><p><br class="table-break" /></p><p>Now, let's put this into practice. </p><div class="example"><a id="e.g.pool.conf"></a><p class="title"><strong>Example 5.8. pool.conf</strong></p><div class="example-contents"><pre class="programlisting"> [global] min pool conn = 5 max pool conn = 10 max member age = 120 [mypool] user = webuser password = secret database = ebiz server = fooserv max pool conn = 7 port = 5000 </pre></div></div><p><br class="example-break" /> The <code class="literal">[global]</code> section defines that we will open 5 connections against the server initially, and will increase up to 10 as demand requires. These connections will be closed after being idle for 2 minutes (120 seconds), but only until there are 5 remaining open.</p><p>The <code class="literal">[mypool]</code> section defines a pool named <code class="literal">mypool</code> that will listen on port 5000. It will login to a <span class="productname">SQL Server</span> named <code class="literal">fooserv</code> using the user <code class="literal">webuser</code> and the ever so clever password of <code class="literal">secret</code>. Once logged in, the connections will use the database <code class="literal">ebiz</code> instead of webuser's default database. Also, since this <span class="productname">SQL Server</span> has a limited number of <acronym class="acronym">CAL</acronym>s (Client Access Licenses), we are restricting the maximum number of connections to 7, which overrides the <code class="literal">global</code> setting of 10.</p><p>Run <span class="command"><strong>tdspool</strong></span> with the name of the pool you are serving. </p><pre class="screen"> <code class="prompt">$ </code><strong class="userinput"><code> tdspool mypool</code></strong></pre><p>Before your clients connect to the pool, you must edit your <code class="filename">freetds.conf</code> to include the host and port of the pooling server, and point your clients at it.</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="appendmode.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="configs.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="stunnel.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appending Dump Files </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> stunnel HOWTO</td></tr></table></div></body></html>