Re: [mongodb-user] Out of semaphores to get db connection and improving throughput

213 views
Skip to first unread message

Scott Hernandez

unread,
Aug 31, 2012, 9:38:49 AM8/31/12
to mongod...@googlegroups.com
It depends on how active your threads are with database operations and
how long the database operations take.

I would suggest increasing your connectionsPerHost to something closer
to the number of threads you have -- for a normal web application
10-100/1 is a reasonable number. If you expect all your threads to do
database operations at the same time then increasing it to the number
of threads is probably your best option.

Can you collection mongostat data from the time when you are seeing
things get this error on the java side?

On Thu, Aug 30, 2012 at 6:36 PM, Paul Kim <pa...@funsockets.com> wrote:
> Hi everybody,
>
> I have about a dozen applications in beta accessing the same Mongo
> standalone database, which in production will be a cluster with master + 2
> slaves. Basically, we started getting "com.mongodb.DBPortPool$SemaphoresOut:
> Out of semaphores to get db connection" error.
>
> Our servers currently can have 256 threads running, any more than that will
> be queued. With mongo java driver, the default will only support up to 50
> threads. That means the mongo connection will fail if server is trying to
> process 50 or more requests.
>
> We changed the threadsAllowedToBlockForConnectionMultiplier in MongoOptions
> to 26. This will make our server support up to 260 mongo threads.
>
> This seemed to resolve the "Out of semaphores" error, but we have started to
> see many queries get backed up and take several tens of seconds to process.
> We would like to increase our throughput to handle this traffic. We are
> considering modifying MongoOptions:
>
> increasing connectionsPerHost
> setting maxWaitTime to non-zero
>
> Is this the right direction to go, or are there other adjustments we should
> be making?
>
> I found this thread mentioning threadsAllowedToBlockForConnectionMultiplier
> and connectionsPerHost.
>
> We are running:
>
> Mongo DB v1.8.1
> Mongo java driver 2.4
> Ubuntu 10.04 64-bit
>
> Thanks,
> Paul.
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb

Scott Hernandez

unread,
Aug 31, 2012, 9:44:07 AM8/31/12
to mongod...@googlegroups.com
I should also mention that we really suggest that you upgrade your
java driver to something recent (2.9) as *many* bugs have been fixed
since 2.4; this also true on the server side. Both of those versions
are fairly old at this point. If nothing else on the server, please
upgrade to 1.8.5 to stay current with important fixes for that major
(1.8.x) version of the server.

Also, please post your MongoOptions when asking questions like this
since you seem to have overridden the defaults.
Reply all
Reply to author
Forward
0 new messages