I wanted to integrate MongoDB into my application. I tested using the Apache Banchmarking tool and made 1,000,000 inbound requests with a level of 1000 concurrency. After some test to insert records in mongodb, I can understand that it inserts about 1000 speeches / sec. But this is not enough for my application. Can anyone suggest the best way to improve perofmance so that I can achieve the 2000 rec / sec goal.
My code is:
private static MongoOptions mo = new MongoOptions(); mo.connectionsPerHost = 20; mo.threadsAllowedToBlockForConnectionMultiplier = 100; private static Mongo m = new Mongo("127.0.0.1",mo); private static DB db = m.getDB("mydb"); private static DBCollection coll = db.getCollection("mycoll"); DBObject dbObj = (DBObject) JSON.parse(msg); db.requestStart(); coll.insert(dbObj); dbObj.removeField("_id"); dbObj.put("val", "-10"); coll.insert(dbObj); db.requestDone();
source share