Surprisingly slow insertion to mongodb capped collections
Looks like the problem is that you're only using fully non-blocking writes when creating the collection (calling create_collection
), not when inserting.
You can disable write acknowledgement at the MongoClient
level as:
mongo = pymongo.MongoClient(w=0)
Or for just the insert
calls as:
coll.insert(msg, w=0)
Either way, the max time drops to 0.001 when I try this locally on a normal disk-backed 3.2 MongoDB instance using WiredTiger storage.