Posts

Showing posts from 2013

Some thoughts on MongoDB Nodejs driver

I am in the process of evaluating mongoDB for one of the product requirements. We were on the J2EE stack and MongoDB has java driver with which we got awesome results compared to the existing framework in terms of not only speed and resource utilization but also in terms data replication and fail-over behavior.

I was curious about mongoDB nodejs driver and tried to test its performance over java driver. It was very easy to write code as I was already familiar with javascript and the footprint, startup time are far less compared to the J2EE stack.

Now comes the real problem with NodeJS. My application typically tries to connect to different database for each request and existing nodejs api does not support to use same driver across different requests rendering the connection pooling offered by the framework useless !!!. I need to create server instance for each request.

With  read preference as NEAREST, the reads are not shared across the replica set members and only the member on whi…

MongoDB index completion status

MongoDB allows you to create indexes and run them in the background using the ensureIndex. Often indexing is a time consuming process and may take long if indexed upon string and the collection contains millions of records. For example, Indexing on my collection having 50 million records took almost 15 minutes. Here is the script that can be used to monitor index operation status.


var ops = db.currentOp();

if(ops.inprog && ops.inprog.length > 0) {
    for(o in ops.inprog) {
        var op = ops.inprog[o];
        if(op.msg && op.msg.match(/bg index build/)) {
            print(op.opid+' - '+op.msg);
        }
    }
}

copy above code into test_index_status.sh, execute mongo index_status.sh and see the magic!!!