Tedious: Best practices for connection lifetime

Created on 30 Nov 2017  路  7Comments  路  Source: tediousjs/tedious

We have a fairly large node project, and are migrating from MongoDB/Cosmos to SQL Azure.

Most of the tedious examples open a single connection, run all of the example SQL commands and the connection is closed before the app exits. Nice and simple.

I am interested in understanding the best strategy for the connection Object lifetime in an express web application serving 10K+ users.

For example - should we open and close a connection after each sql call is executed? This is usually the norm in .NET/C#. ADO would handle the pooling, which you could configure in the connection string.

Interested in hearing advice and ideas/war stories from users of this library.

Follow up

Most helpful comment

Check out https://github.com/tediousjs/tedious-connection-pool

I believe this library is out of date

All 7 comments

@tvrprasad thanks.

So, typically within a data access component / service you would reference the pool file (which would look like the example in the link above, without the actual query) and then acquire a connection, perform data operations and release it back to the pool?

Yes, that would be the right way to do it.

@tvrprasad Are there any plans to upgrade the version of Tedious in use in that library? I'm asking here because it looks like several people have filed issues and merge requests attempting to do so, but no one has responded.

@dcherman I'm not currently active on the project. See #690 where @v-suhame recommended https://www.npmjs.com/package/mssql and https://www.npmjs.com/package/sequelize.

@dcherman I'll try and take a look. I've not contributed to tedious-connection-pool before - and I'm not sure if I can actually release a new version.

Check out https://github.com/tediousjs/tedious-connection-pool

I believe this library is out of date

Was this page helpful?
0 / 5 - 0 ratings