I'm using the node-mssql package to create an API endpoint in Node.
I am wondering how the package handles connection pooling, as there isn't much explained about it on the package website.
I have the following in my configuration, to allow the pool to go up to 10.
var config = {
server: '',
user: '',
password: '',
database: '',
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 30000
}
}
I've added these lines to each request, so I can see what's going on in the Node console...
// Dump info about connection pool
console.log('SQL Pool - waitingClientsCount: ' + connection.pool.waitingClientsCount())
console.log('SQL Pool - getPoolSize: ' + connection.pool.getPoolSize())
console.log('SQL Pool - availableObjectsCount: ' + connection.pool.availableObjectsCount())
I've navigated to the endpoint in my browser and held refresh for a good few minutes. In the Node console, every output from the above, is like this...
SQL Pool - waitingClientsCount: 0
SQL Pool - getPoolSize: 1
SQL Pool - availableObjectsCount: 0
I was expecting the pool size to increase with all these requests.
Does the pool automatically configure itself based on load, or am I misunderstanding something?
EDIT: The package is using the Tedious driver by the looks of it.
Found the answer in the projects Issue Tracker on GitHub: https://github.com/patriksimek/node-mssql/issues/118#issuecomment-92522160
The answer is...
Clarkey, IIRC the default pool size is 10, and if your requests return fast enough... the first connection will simply be reused... if you use something like siege if you really want to test things. Also, iirc the connection will stay open for something like 30 or 60 seconds before being cycled out.