I am currently performing some benchmarks on my application using Vert.x and I am trying to compare results when I use the mongo java sync or async driver.
And to my surprise, the results seems to be far better with the sync driver, because it uses really few mongodb connections compared to the async one. As a consequence, the mongo requests are slower and mongo always finished by crashing with async driver.
Is this normal that the async driver open so many connections compared to the sync one ? If yes, do we need to install mongo as a replica set to better scale with async driver ?
For example, here are results of test with wrk with 200 connections in 30 seconds with 16 threads.
With Sync driver:
~ • wrk -t16 -c200 -d30s http://localhost:8080/f0e7a0f5/status
Running 30s test @ http://localhost:8080/f0e7a0f5/status
16 threads and 200 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 131.90ms 42.75ms 567.64ms 78.19%
Req/Sec 92.61 21.28 171.00 66.36%
43997 requests in 30.10s, 3.23MB read
Socket errors: connect 0, read 55, write 0, timeout 0
Requests/sec: 1461.89
Transfer/sec: 109.93KB
With Async driver (mongodb crashes) :
~ • wrk -t16 -c200 -d30s http://localhost:8080/f0e7a0f5/status
Running 30s test @ http://localhost:8080/f0e7a0f5/status
16 threads and 200 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 424.87ms 205.89ms 1.38s 73.84%
Req/Sec 31.68 20.04 118.00 64.01%
13597 requests in 30.11s, 1.00MB read
Socket errors: connect 0, read 31, write 0, timeout 0
Requests/sec: 451.65
Transfer/sec: 33.96KB
- MongoDB 3.2.7 WiredTiger
- Mongo Java Driver 3.2.2
- Vertx 3.3.1
- Mac OS X El Capitan 2.5 Ghz I7 16 Go RAM
UPDATE 1 : I solved the mongodb crash problem on my local machine by configuring files and process limits : https://unix.stackexchange.com/questions/108174/how-to-persist-ulimit-settings-in-osx-mavericks However, I still have many opened connections with the async driver, which slow my application.
UPDATE 2 : Here is some code with the async driver. The verticle : http://pastebin.com/SygKuDhg
The config :
"mongo-platform" : {
"pool_name": "mongo-platform",
"host": "localhost",
"port": 27017,
"db_name": "mongo_platform",
"maxPoolSize": 250,
"minPoolSize": 20,
"useObjectId": true
}
UPDATE 3: And here is the code for the sync driver
I use Jongo as a wrapper of the java sync driver and vertx-hk2 for dependency injection into my REST verticle.