top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Scala driver and too many connections issue with mongodb

0 votes
301 views

We recently starting using MongoDB and the new Scala driver library (v 1.1.1). We have not made any custom configurations but we are consistently running out of connections and getting connection timeouts. I worry that we are using the driver incorrectly.

Please see my questions below -

  1. We are using dependency injection to manage the MongoClient. Should be injecting MongoClient or MongoDatabase into all of our CRUD classes?
  2. Should we treat the MongoClient and/or the MongoDatabase as a singleton?
  3. Are there any other common mistakes people have seen with the Scala driver?

Thanks in advance...

posted Jun 30, 2016 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+1 vote

With the non-blocking asynchronous mongo java/scala driver, it is possible to define a wait time and a wait queue size for operations that cannot be executed directly with a free connection. When settings these values, the mongo driver will make the threads waiting for an available connection.

This behavior is very dangerous for an application written with non-blocking asynchronous IO in mind. These applications use a very limited number of threads (= numbers of cores). Blocking one of these thread can block the whole application.

What would be the recommended way to for this kind of applications? Should we set all these waiting settings to 0 and handle MongoWaitQueueFullException with retries in the application? Should the driver call an application callback when a connection is free?

+1 vote

I recently upgraded the latest PHP driver and could do an "explain" query by using the "$explain" modifier when executing the query, however as of MongoDB 3.2 the operator was removed so this is no longer possible.

So my question is how can I do an explain query with the new driver and MongoDB 3.2?

0 votes

My collection is like this, but I want to update a nested object with {"env":"qa"} in my updated collection with java-driver:

{ "_id" : ObjectId("5b052eeff9290437b217b1ed"), "app" : "hike", "group" : [ { "env" : "prod" }, { "env" : "test" } ]}{ "_id" : ObjectId("5b052f36f9290437b217b1ee"), "app" : "viber", "group" : [ { "env" : "prod" }, { "env" : "test" } ]}

...