MongoDB: odd write performance

I came across odd write performance using MongoDB 3.0.5 and mongo java driver 2.13.1. If the application is idle for a specified period of time, the next recording will take about 17 seconds, then any subsequent recordings will be immediate. The previous reading is just milliseconds. There are only a few dozen entries, and they are all quite small. Using the Write Concern function, which is ACKNOWLEDGE. So, as observed, with exactly the same number of records and size:

Idle. Read ~ 10 ms. Write 17 seconds. Read ~ 10 ms. Write ~ 25 ms.

The sample code is simple, with a rudimentary timer for the above results:

Long timer = System.currentTimeMillis();
Stack<BasicDBObject> stack = new Stack<>();
DBCursor cloneCursor = cloneMongo.getCollection("ourCollection").find();
while (cloneCursor.hasNext())
{
    BasicDBObject cloneRec = (BasicDBObject) cloneCursor.next();
    if (cloneRec.containsField("name"))
    {
    if (cloneRec.getString("name").equals("project"))
    {
        cloneRec.put("default", destProject.getID());
    }
    }
    stack.add(cloneRec);
}
Util.print("Clone - Clone Read:"+(System.currentTimeMillis() - timer), 1);
DBCollection collection = cloneMongo.getCollection("collection2");
BulkWriteOperation bulkOp = collection.initializeUnorderedBulkOperation();
Util.print("Clone - Clone DestConnect:"+(System.currentTimeMillis() - timer), 1);
while (!stack.isEmpty())
{
    bulkOp.insert(stack.pop());
}
bulkOp.execute();
Util.print("Clone - Clone Write:"+(System.currentTimeMillis() - timer), 1);

Platter, FusionIO 15- SAS-, , -. , 17 Second write .

, , (~ 10 ) ( ) . , , , , "".

MongoDB ?

+4

All Articles