What is the best MongoDB driver that supports replica sets

do you have any suggestions what the best way is for using mongodb with replica sets?

Has anyone experience with this driver:

the one from eric isunfortunately not supporting replica sets:

thanks in advance.

2 Likes

The author of mongox created a PR [1] for mongodb for adding support of replica sets but it was never merged because it lacked tests. It seems the support for replica sets was added in a fork instead.

There is now another PR [2] for replica sets in mongodb that has proper tests and is almost finished.

A few changes has happened to mongodb after the fork, the big ones being that it now uses the db_connection library and optimized binary handling. With db_connection the pooling was changed to a better API and you can use all pools that db_connection support. I am sure there have been changes to mongox since the fork also so I think you should try both libraries and see which one you prefer.

[1] https://github.com/ericmj/mongodb/pull/67
[2] https://github.com/ericmj/mongodb/pull/93

3 Likes

thanks for your reply.

is the version from your pull request already usable? I would like to use it, as we are already using your driver (with the ecto integration). it works very well locally, but we recognized, that it does not work on our production systems, as it does not work with replica sets.this is our first try with elixir and if we do not get it to work with replica sets, we would have to switch back to another language.

so I will try it tomorrow and hopefully I will get is to work.

2 Likes

does anybody have an example how to connect to a mongodb with replica sets – with whatever driver? Up to now we were not able to get this working. And if we can’t connect to a mongodb we will have to switch back from elixir to another language, that supports this.

kind regards