Skip to content

Create connections at database level, not collection level#44

Merged
jimlambie merged 10 commits intomasterfrom
feature/connect_once
Mar 23, 2016
Merged

Create connections at database level, not collection level#44
jimlambie merged 10 commits intomasterfrom
feature/connect_once

Conversation

@jimlambie
Copy link
Contributor

Close #43

This pull request modifies the connection module so that it will only create a connection for each distinct database that is requested, rather than for each collection. With the default pool size of 5 connections, opening a connection to the database for each collection means the open connections can spin out of control rapidly.

Opening one connection per database aims to reduce the number of open connections.

@joewagner @josephdenne @eduardoboucas I'd appreciate some input from you guys if you have some time.

@eduardoboucas
Copy link
Contributor

The principles makes complete sense to me and the implementation looks good. 👍

* @api public
*/
module.exports = function (options) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the check for an existing connection on line 222 be moved above the new Connection(options); call? If the connection exists, no need to instantiate a new one.

@joewagner
Copy link

This looks great! I had one question on implementation that I put into a line comment

@jimlambie
Copy link
Contributor Author

Awesome, thanks guys! @joewagner great point, have pushed an update to this effect.

@jimlambie jimlambie merged commit e005e24 into master Mar 23, 2016
@jimlambie jimlambie deleted the feature/connect_once branch August 3, 2016 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants