understanding poolSize

1,621 views
Skip to first unread message

Sam Darwin

unread,
Apr 29, 2013, 9:08:52 AM4/29/13
to mongoo...@googlegroups.com
Hi,

I have a few questions about using connection pools with mongoose.

- If the poolSize is 5, which is the default, does that mean that a maximum of 5 connections will be open from the app to the db?

- If we are seeing 1000's of connections from the app to the db, even to the point of overloading the server with connections, what does that indicate?     that pools aren't being used,  or maybe that the pool setting was misconfigured?

- for capacity planning on a busy site with 10000's of end-users connecting, what might be an optimal poolSize, and how many connection would that cause?    does poolsize=# of observed connections?

Thanks.


Sam Darwin

unread,
Apr 29, 2013, 2:13:27 PM4/29/13
to mongoo...@googlegroups.com
To clarify one of those points, there are many servers, and on each server there are more than one process running.    so that would certainly be an explanation for the many connections.       Still, I wonder if multiple threads or subprocesses are spawned, if more than one db or collection is connected to, etc,   what the formula is for # of connections, and what settings value are recommended, what the implications of having too small or too large value.   a blog post maybe.  :-)

Aaron Heckmann

unread,
Apr 29, 2013, 5:53:09 PM4/29/13
to mongoo...@googlegroups.com
Per process, each mongoose connection is backed by a connection pool that defaults to a size of 5. this means that 5 connections + 1 are opened to each node in your replica set. The "plus 1" is to monitor the health of the cluster and provide high availability. When any connection dies the driver will connect a new one to take its place.

poolSize is scoped per "connection" which in mongoose is either:

  - the default connection - in use when calling mongoose.connect(uri)
  - new connections - when calling mongoose.createConnection(uri)

Mongodb max number of connections is 20,000.

By default all writes are acknowledged with getLastError (this can be disabled but not really recommended). In practice, a poolSize of 1 (a single connection in the pool) results in all reads/writes getting queued up until the acknowledgement returns. Hence the higher default makes sense.




On Mon, Apr 29, 2013 at 11:13 AM, Sam Darwin <samuel....@gmail.com> wrote:
To clarify one of those points, there are many servers, and on each server there are more than one process running.    so that would certainly be an explanation for the many connections.       Still, I wonder if multiple threads or subprocesses are spawned, if more than one db or collection is connected to, etc,   what the formula is for # of connections, and what settings value are recommended, what the implications of having too small or too large value.   a blog post maybe.  :-)

--
Documentation - http://mongoosejs.com/
Plugins - http://plugins.mongoosejs.com/
Bug Reports - http://github.com/learnboost/mongoose
Production Examples - http://mongoosejs.tumblr.com/
StackOverflow - http://stackoverflow.com/questions/tagged/mongoose
Google Groups - https://groups.google.com/forum/?fromgroups#!forum/mongoose-orm
Twitter - https://twitter.com/mongoosejs
IRC - #mongoosejs
---
You received this message because you are subscribed to the Google Groups "Mongoose Node.JS ODM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-orm...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Aaron


Reply all
Reply to author
Forward
0 new messages