Use single connection pool for cluster vs multiple connection pool for each child process in mongodb-native NodeJS
Asked Answered
R

1

7

I'm implementing a nodejs server which is using mongodb as database and mongodb-native library to connect it.

Further, I'm using clustering to enhance the server performances. So there are two possible ways to use mongodb-native driver's connection pooling;

  1. Create a single connection pool and pass it to each child process when creating them (singleton pattern)
  2. After a child process created, creates a connection pool internally

So, my question is, what's the best methods among two of them? Or is there any other good method to do so?

Richellericher answered 6/5, 2014 at 8:7 Comment(0)
V
0

It depends on your application purposes. Remeber that creating a new pool it's much more expensive than reusing the same pool. Usually I would use option 1, but I repeat, it depends on your application. If all the child processes do an intensive use of db operations maybe it's better to use option 2.

Vicar answered 6/12, 2014 at 15:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.