C++ Reliable Connection to Multiple MongoDBs for HA

70 views
Skip to first unread message

Kazuki Ohta

unread,
Jun 14, 2010, 1:05:25 AM6/14/10
to mongodb-user
Hello, Mongo community

We're now considering to use MongoDB, as a backend database of our
enterprise search engine. It perfectly fits our purpose. Thanks for
the great product.

Now I have one question. We're using C++ client, and MongoDB Master-
Master replication for High Availability (This is because Replica Pair
will be obsoleted). In this situation, how to get the reliable
connection to two different servers?

The problems are...

(1) DBClientPaired is for Replica Pairs, but will be obsoleted.
(2) ScopedDbConnection is nice for pooling, but takes one server.

For master-master replication, should we use ScopedDbConnection and
implement failover manually? Or using DBClientPaired also will be used
for Replica Sets?

Thanks in advance
Kazuki

Eliot Horowitz

unread,
Jun 14, 2010, 1:07:28 AM6/14/10
to mongod...@googlegroups.com
Even thought replica pairs are going to be replaced, I would still
recommend using them over master/master.

They handle a lot of the error cases and will be an easy upgrade to
replica sets.

Then you should use DBClientPaired

> --
> 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.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

Kazuki Ohta

unread,
Jun 14, 2010, 1:20:01 AM6/14/10
to mongodb-user
Hi, Ellot

Thanks for the extremely fast reply!!!

We'll use the DBClientPaired.
But we also want to pool the connection. Any good solution for that?

As far as I read the source code, passing the hosts to
ScopedDbConnection
in comma separated style, creates the DbClientPaired internally.

> ScopedDbConnection c("host01, host02");
- http://github.com/mongodb/mongo/blob/master/client/connpool.cpp#L31

Should this the appropriate solution?

Thanks in advance
Kazuki

Eliot Horowitz

unread,
Jun 14, 2010, 7:26:25 AM6/14/10
to mongod...@googlegroups.com
Yes - that is correct.
We'll be making this less magical soon and more explicit, but same idea.
Reply all
Reply to author
Forward
0 new messages