Skip to content

Commit 280863c

Browse files
committed
Some thread and pool sizing doc updates
1 parent d96e5db commit 280863c

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

doc/api.md

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -760,9 +760,12 @@ The default value is 4.
760760

761761
This property may be overridden when [creating a connection pool](#createpool).
762762

763-
If you increase this value, you should increase the number of threads
763+
See [Connections and Number of Threads](#numberofthreads) for why you
764+
should not increase this value beyond 128. Importantly, if you
765+
increase `poolMax` you should also increase the number of threads
764766
available to node-oracledb.
765-
See [Connections and Number of Threads](#numberofthreads).
767+
768+
See [Connection Pooling](#connpooling) for other pool sizing guidelines.
766769

767770
##### Example
768771

@@ -2682,17 +2685,22 @@ oracledb.getConnection(
26822685
26832686
If you open more than four connections, such as via
26842687
increasing [`poolMax`](#proppoolpoolmax), you should increase the
2685-
number of threads available to node-oracledb.
2688+
number of worker threads available to node-oracledb.
2689+
2690+
The thread pool size should be at least equal to the maxiumum number
2691+
of connections. If the application does database and non-database
2692+
work concurrently, extra threads could also be required for optimal
2693+
throughput.
26862694
2687-
Node.js worker threads executing database statements on a connection will
2688-
commonly wait until round-trips between node-oracledb and the database
2689-
are complete. When an application handles a sustained number of user
2690-
requests, and database operations take some time to execute or the
2691-
network is slow, then the four default threads may all be held in
2695+
Node.js worker threads executing database statements on a connection
2696+
will commonly wait until round-trips between node-oracledb and the
2697+
database are complete. When an application handles a sustained number
2698+
of user requests, and database operations take some time to execute or
2699+
the network is slow, then the four default threads may all be held in
26922700
use. This prevents other connections from beginning work and stops
26932701
Node.js from handling more user load. Increasing the number of worker
2694-
threads may improve throughput. Do this by setting the environment
2695-
variable
2702+
threads may improve throughput and prevent [deadlocks](https://github.com/oracle/node-oracledb/issues/603#issuecomment-277017313). Do this by
2703+
setting the environment variable
26962704
[UV_THREADPOOL_SIZE](http://docs.libuv.org/en/v1.x/threadpool.html)
26972705
before starting Node.
26982706
@@ -2703,13 +2711,15 @@ can be increased to 10 by using the following command:
27032711
$ UV_THREADPOOL_SIZE=10 node myapp.js
27042712
```
27052713
2706-
The thread pool size should be at least equal to the maxiumum number
2707-
of connections. If the application does database and non-database
2708-
work concurrently, extra threads could also be required for optimal
2709-
throughput.
2714+
If the value is set inside the application with
2715+
`process.env.UV_THREADPOOL_SIZE` ensure it is set prior to any
2716+
asynchronous call that uses the thread pool otherwise the default size
2717+
of 4 will be used.
27102718
27112719
Note the '[libuv](https://github.com/libuv/libuv)' library used by
2712-
Node.js limits the number of threads to 128.
2720+
Node.js limits the number of threads to 128. This implies the
2721+
maxiumum number of connections opened, i.e. `poolMax`, should be less
2722+
than 128.
27132723
27142724
### <a name="connpooling"></a> 8.3 Connection Pooling
27152725
@@ -3035,7 +3045,7 @@ One related environment variable is is shown by `_logStats()`:
30353045
30363046
Environment Variable | Description
30373047
-----------------------------------------------------|-------------
3038-
[`process.env.UV_THREADPOOL_SIZE`](#numberofthreads) | The number of worker threads for this process.
3048+
[`process.env.UV_THREADPOOL_SIZE`](#numberofthreads) | The number of worker threads for this process. Note, if this variable is set after the thread pool starts it will be ignored and the thread pool will still be restricted to the default size of 4.
30393049
30403050
#### <a name="connpoolpinging"></a> 8.3.4 Connection Pool Pinging
30413051

0 commit comments

Comments
 (0)