Skip to content

added MONGO_MAX_POOL_SIZE and MONGO_USE_GREENLETS parameters#15

Closed
akhenakh wants to merge 4 commits into
mongodb-labs:masterfrom
akhenakh:master
Closed

added MONGO_MAX_POOL_SIZE and MONGO_USE_GREENLETS parameters#15
akhenakh wants to merge 4 commits into
mongodb-labs:masterfrom
akhenakh:master

Conversation

@akhenakh
Copy link
Copy Markdown
Contributor

I'm using flask-pymongo with gevent and this parameters are usefull for tuning.

Comment thread flask_pymongo/__init__.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line doesn't seem to be doing anything ... typo?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oops fixed !

@dcrosta
Copy link
Copy Markdown
Contributor

dcrosta commented Nov 14, 2012

Hey @ajdavis, I'm a little unfamiliar with how these arguments are intended to be used -- can you offer any insight as to whether this approach is workable and correct?

@ajdavis
Copy link
Copy Markdown

ajdavis commented Nov 14, 2012

Hey Dan! Summary: max_pool_size is fine, but leave validation up to PyMongo. Don't expose use_greenlets.

max_pool_size is the horrifically-named option to control how many idle sockets the pool will keep open when they're returned to the pool (via end_request, or when a thread dies). So it's better thought of as "max idle sockets before I start closing any more that are returned to the pool."

It's far, far less frequently useful than anyone thinks. I'd venture to call it useless. People want it to mean "max concurrent connections allowed," but PyMongo has no such option. However, if you want to make max_pool_size configurable this is a fine way to do it.

I strongly recommend not validating it at all, since Connection or ReplicaSetConnection will much more thoroughly validate the parameter. Thus it's redundant and likely buggy to do your own validation here.

use_greenlets: please don't set this. We're removing it from public view very soon. Our idea was that you could either do gevent.monkey.patch_all(), or use gevent and set use_greenlets=True. We've changed our minds and we can't think of any good reason not to just do patch_all(), so we're going to legislate that and hide use_greenlets as best we can.

let pymongo Connection validate MAX_POOL_SIZE
changed doc accordingly
@akhenakh
Copy link
Copy Markdown
Contributor Author

Thanks @ajdavis and Dan

Comment thread docs/index.rst
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Per @ajdavis we should probably note that this is the maximum number of idle connections that will be left open.

@dcrosta
Copy link
Copy Markdown
Contributor

dcrosta commented Nov 15, 2012

Looks great other than my one last nitpick comment.

@ajdavis
Copy link
Copy Markdown

ajdavis commented Nov 15, 2012

Yeah. "The maximum size limit for the connection pool" is copied from PyMongo's docs, but that's a very unfortunately unclear description. I agree with @dcrosta .

@dcrosta
Copy link
Copy Markdown
Contributor

dcrosta commented Dec 15, 2012

Thanks! Sorry it took me a while to get around to merging this.

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