Scala Driver: Connecting to multiple "mongos" nodes

52 views
Skip to first unread message

Markus Lachinger

unread,
Aug 13, 2016, 6:18:11 AM8/13/16
to mongodb-user
Hi,

I have multiple mongos nodes that are connected to my sharded database to prevent a single point of failure. If I now start a Scala app using the official driver and specify i.e. three nodes in my MongoDB connection string, what will happen?

Will it pick the first one for all traffic, will it round robin the requests to all? Will it know about load of the mongos?

Thanks

Wan Bachtiar

unread,
Aug 22, 2016, 4:28:08 AM8/22/16
to mongodb-user

If I now start a Scala app using the official driver and specify i.e. three nodes in my MongoDB connection string, what will happen?

Hi Markus,

The MongoDB Scala Driver implementation is built upon the MongoDB Async Java Driver.

Based on the Driver: Server Selection Specification the Java driver implemented LatencyMinimizingServerSelector, which will load balance all operations across the available mongos servers using the following consideration:

  • Lowest latency mongos plus all mongos within specified latency window
  • Random selection to ensure a fair distribution of work within the latency window.

For example, if there are three mongos: ms1, ms2, and ms3, whose ping times are 10, 15, and 16 milliseconds, respectively. If local latency window specified is 5 milliseconds, the selection would be either ms1 or ms2 (randomly selecting between the two).

The default local latency window value is 15 milliseconds.

See also :

Regards,

Wan.

Markus Lachinger

unread,
Aug 26, 2016, 4:59:30 PM8/26/16
to mongodb-user
Thank you very much Wan, these resources are of great help!

Best,
Markus
Reply all
Reply to author
Forward
0 new messages