Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB: How often should you open and close the database? Why?

For every request I was opening the database, querying, closing the database.

I was sporadically running into a connection already opened issue.

I ended up changing the configuration to just open mongo and keep it open.

What are the downsides to this method?

Thanks!

(note: using node.js)

like image 530
fancy Avatar asked Sep 10 '11 19:09

fancy


Video Answer


1 Answers

I looks as if you should open the connection once and keep reusing it, at least with the node-native-driver. Comments on the subject by the driver's developer found here: https://github.com/mongodb/node-mongodb-native/issues/84

like image 143
fancy Avatar answered Oct 03 '22 23:10

fancy