Skip to content

Commit 3e8a08a

Browse files
committed
Update pool sizing guidance
1 parent 2eb82e9 commit 3e8a08a

File tree

1 file changed

+51
-20
lines changed

1 file changed

+51
-20
lines changed

doc/api.md

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,13 @@ request exceeds the number of currently open connections.
16821682

16831683
The default value is 1.
16841684

1685+
With fixed-sized [homogeneous](#createpoolpoolattrshomogeneous) pools (where
1686+
`poolMin` equals `poolMax`), and using Oracle Client 18c (or later), you may
1687+
wish to evaluate setting `poolIncrement` greater than 0. This can expedite
1688+
regrowth when the number of [connections established](#proppoolconnectionsopen)
1689+
has become lower than `poolMin`, for example if network issues have caused
1690+
connections to become unusable and they have been dropped from the pool.
1691+
16851692
This property may be overridden when [creating a connection pool](#createpool).
16861693

16871694
##### Example
@@ -5665,16 +5672,21 @@ readonly Number connectionsInUse
56655672

56665673
The number of currently active connections in the connection pool
56675674
i.e. the number of connections currently "checked out" using
5668-
`getConnection()`.
5675+
`pool.getConnection()`.
56695676

56705677
#### <a name="proppoolconnectionsopen"></a> 8.1.2 `pool.connectionsOpen`
56715678

56725679
```
56735680
readonly Number connectionsOpen
56745681
```
56755682

5676-
The number of currently open connections in the underlying connection
5677-
pool.
5683+
The current number of connections in the pool that are connected through to the
5684+
database. This number is the sum of connections in use by the application, and
5685+
connections idle in the pool.
5686+
5687+
It may be less than `poolMin` if connections have been dropped, for example
5688+
with `await connection.close({drop: true})`, or if network problems have caused
5689+
connections to become unusable.
56785690

56795691
#### <a name="proppoolenablestatistics"></a> 8.1.3 `pool.enableStatistics`
56805692

@@ -8998,14 +9010,20 @@ See [webapp.js][189] for a runnable example.
89989010

89999011
#### <a name="conpoolsizing"></a> 15.3.1 Connection Pool Sizing
90009012

9001-
The characteristics of a connection pool are determined by its attributes
9013+
The main characteristics of a connection pool are determined by its attributes
90029014
[`poolMin`](#proppoolpoolmin), [`poolMax`](#proppoolpoolmax),
90039015
[`poolIncrement`](#proppoolpoolincrement), and
90049016
[`poolTimeout`](#proppoolpooltimeout).
90059017

9006-
Importantly, if you increase the size of the pool, you must increase the number
9007-
of threads used by Node.js before Node.js starts its threadpool. See
9008-
[Connections, Threads, and Parallelism](#numberofthreads).
9018+
**Importantly, if you increase the size of the pool, you must increase the number
9019+
of threads used by Node.js before Node.js starts its thread pool. See
9020+
[Connections, Threads, and Parallelism](#numberofthreads)**.
9021+
9022+
Setting `poolMin` causes the specified number of connections to be established
9023+
to the database during pool creation. This allows subsequent
9024+
`pool.getConnection()` calls to return quickly for an initial set of users. An
9025+
appropriate `poolMax` value avoids overloading the database by limiting the
9026+
maximum number of connections ever opened.
90099027

90109028
Pool expansion happens when the following are all true: (i)
90119029
[`pool.getConnection()`](#getconnectionpool) is called and (ii) all the
@@ -9015,9 +9033,9 @@ number of those connections is less than the pool's `poolMax` setting.
90159033

90169034
Pool shrinkage happens when the application returns connections to the pool,
90179035
and they are then unused for more than [`poolTimeout`](#propdbpooltimeout)
9018-
seconds. Any excess connections above `poolMin` will then be closed. Prior to
9036+
seconds. Any excess connections above `poolMin` will be closed. Prior to
90199037
using Oracle Client 21, this pool shrinkage was only initiated when the pool
9020-
was accessed.
9038+
was later accessed.
90219039

90229040
For pools created with [External Authentication](#extauth), with
90239041
[`homogeneous`](#createpoolpoolattrshomogeneous) set to *false*, or when using
@@ -9029,17 +9047,16 @@ number of open connections exceeds `poolMin` then the number of open
90299047
connections does not fall below `poolMin`.
90309048

90319049
The Oracle Real-World Performance Group's recommendation is to use fixed size
9032-
connection pools. The values of `poolMin` and `poolMax` should be the same (and
9033-
`poolIncrement` equal to zero). This avoids connection storms which can
9034-
decrease throughput. See [Guideline for Preventing Connection Storms: Use
9035-
Static Pools][23], which contains more details about sizing of pools. Having a
9036-
fixed size will guarantee that the database can handle the upper pool size. For
9037-
example, if a pool needs to grow but the database resources are limited, then
9038-
`pool.getConnection()` may return errors such as *ORA-28547*. With a fixed pool
9039-
size, this class of error will occur when the pool is created, allowing you to
9040-
change the size before users access the application. With a dynamically growing
9041-
pool, the error may occur much later after the pool has been in use for some
9042-
time.
9050+
connection pools. The values of `poolMin` and `poolMax` should be the same.
9051+
This avoids connection storms which can decrease throughput. See [Guideline
9052+
for Preventing Connection Storms: Use Static Pools][23], which contains more
9053+
details about sizing of pools. Having a fixed size will guarantee that the
9054+
database can handle the upper pool size. For example, if a pool needs to grow
9055+
but the database resources are limited, then `pool.getConnection()` may return
9056+
errors such as *ORA-28547*. With a fixed pool size, this class of error will
9057+
occur when the pool is created, allowing you to change the size before users
9058+
access the application. With a dynamically growing pool, the error may occur
9059+
much later after the pool has been in use for some time.
90439060

90449061
The Real-World Performance Group also recommends keeping pool sizes small, as
90459062
this may perform better than larger pools. Use
@@ -9048,6 +9065,20 @@ this may perform better than larger pools. Use
90489065
attributes should be adjusted to handle the desired workload within the bounds
90499066
of resources available to Node.js and the database.
90509067

9068+
When the values of `poolMin` and `poolMax` are the same, and you are using
9069+
Oracle Client 18c (or later), then `poolIncrement` can be set greater than
9070+
zero. This changes how a [homogeneous pool](#createpoolpoolattrshomogeneous)
9071+
grows when the number of [connections established](#proppoolconnectionsopen)
9072+
has become lower than `poolMin`, for example if network issues have caused
9073+
connections to become unusable and they have been dropped from the pool.
9074+
Setting `poolIncrement` greater than 1 in this scenario means the next
9075+
`pool.getConnection()` call that needs to grow the pool will initiate the
9076+
creation of multiple connections. That `pool.getConnection()` call will not
9077+
return until the extra connections have been created, so there is an initial
9078+
time cost. However it can allow subsequent connection requests to be
9079+
immediately satisfied. In this growth scenario, a `poolIncrement` of 0 is
9080+
treated as 1.
9081+
90519082
Make sure any firewall, [resource manager][101] or user profile
90529083
[`IDLE_TIME`][100] does not expire idle connections, since this will require
90539084
connections to be recreated which will impact performance and scalability. See

0 commit comments

Comments
 (0)