Create connections at database level, not collection level#44
Merged
Create connections at database level, not collection level#44
Conversation
Contributor
|
The principles makes complete sense to me and the implementation looks good. 👍 |
| * @api public | ||
| */ | ||
| module.exports = function (options) { | ||
|
|
There was a problem hiding this comment.
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.
|
This looks great! I had one question on implementation that I put into a line comment |
Contributor
Author
|
Awesome, thanks guys! @joewagner great point, have pushed an update to this effect. |
…than each collection connection
…to feature/connect_once
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.