0

Do node.js applications benefit from database connection pooling or not?

I assume in some cases they would benefit from a pool of connections and in some cases they wouldn't benefit from more than 1 connection. Can someone please describe a few simple scenarios that support both standpoints?

6
  • This depends on how you construct your application. There is no yes/no answer to this question. If you want to use connection pooling, use connection pooling. If not, don't. It's up to you. Node.js itself has no database bindings. For that, you need to install packages, and there are many to choose from. Commented Nov 12, 2014 at 20:07
  • thanks, what do you mean by database bindings? you may mean node.js is not bound to a particular DB vendor? Commented Nov 12, 2014 at 21:50
  • is there a particular node.js module that can manage synchronized access to a mongodb collection pool? any recommendations? Commented Nov 12, 2014 at 21:51
  • no. only asynchronously access. but you can use github.com/caolan/async#waterfall for executing queries in series and high level mongoosejs.com orm to speed up development and improve code Commented Nov 12, 2014 at 22:29
  • 1
    @AlexMills Node.js itself has no provisions for connecting to a database. There are modules available for connecting to databases. The concept of a database isn't even built into Node.js. It has a very light framework for accessing disk and network. That's about it. Commented Nov 12, 2014 at 22:44

1 Answer 1

1

If you have clustered database (for example, 1 master server and few read only replicas) pooling will help. Also you need to account the connection time needed to establish connection to database. If you use pooling, you alwayes have few already established connection ready to perform requests

Sign up to request clarification or add additional context in comments.

1 Comment

ok seems like a pool of at least 2 db connections is superior most of the time to just one

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.