If you want to connect your Scala application to MongoDB you have two choices, really. You can use the official driver, which comes in two flavors (Java Async Driver or Scala driver, which is just a facade with RxScala API). Alternatively you can go with ReactiveMongo, a completely new approach built on top of Akka. I ran some microbenchmarks to compare them.
I tested inserting and getting documents in three test suites and varies size in each one:
- Small documents: only four flat fields. Consecutive test cases included documents with longer and longer strings as values.
- Nested documents: binary tries, up to the depth of 10
- Multi-field documents: docs with up to one thousand keys.
Here is a chart comparing times of inserting and getting nested small documents:
As you can see, the differences in response times are negligible. The charts look similar for other suites as well.
I wanted to run the same suites with all three drivers. That was easy for one-shot operations, but would be unfair for bulk ops. Since ReactiveMongo is based on Akka and has an Iteratee interface, while Scala driver uses RxScala, any comparison would require converting one to another, which would be unfair. So, streaming efficiency was not tested.
The bottom line is, you should probably choose the driver based on its API. If you already use Akka – go for ReactiveMongo. If you want to plug the DB into a Play app – check out the Play-ReactiveMongo module. If you’d rather use RxScala or are worried that ReactiveMongo will not follow new MongoDB releases quickly enough – take the official driver.