I'm reviewing the mongo profiling data and noticed that there is one update job took nearly 15 seconds. The code was trying to update some user data in the User collection which has about 120K entries.
Here's the profile output:
{
"ts" : ISODate("2013-05-24T12:59:44.610Z"),
"op" : "update",
"ns" : "gf2.User",
"query" : {
"_id" : "gfu-iqckom"
},
"updateobj" : {
"$set" : {
"random" : [
0.040397967884538866,
0.9845285429580969
],
"games" : [
{
"trophies" : [
{
"date" : 1369322506.962343,
"id" : "welcome"
},
{
"date" : 1369323539.185573,
"id" : "fb_connect"
}
]
},
{
"timestamp" : 1369400360,
"data" : {
"create_tm" : 1369400360.618168
},
"name" : "xxxxxx"
}
],
"update_tm" : 1369400360.618263
}
},
"nscanned" : 1,
"moved" : true,
"nmoved" : 1,
"nupdated" : 1,
"keyUpdates" : 0,
"numYield" : 0,
"lockStats" : {
"timeLockedMicros" : {
"r" : NumberLong(0),
"w" : NumberLong(14833109)
},
"timeAcquiringMicros" : {
"r" : NumberLong(0),
"w" : NumberLong(2985)
}
},
"millis" : 14833,
"client" : "10.0.0.12",
"user" : ""
}
And the stats for the relevant collection:
rssh1:PRIMARY> db.User.stats()
{
"ns" : "gf2.User",
"count" : 125872,
"size" : 1421237056,
"avgObjSize" : 11291.129528409812,
"numExtents" : 23,
"nindexes" : 7,
"paddingFactor" : 1.020000001594492,
"systemFlags" : 0,
"userFlags" : 0,
"indexSizes" : {
"_id_" : 5338928,
"user_id_1" : 5486096,
"fbID_1" : 5052768,
"email_1" : 7113120,
"tags.facebook_friends_1" : 1980783168,
"random" : 1087408
},
"ok" : 1
}
This mongod is the primary of the 2 nodes replica set(including one arbiter node). The secondary is currently in the resync process. The client code is using pymongo and the write concern level is only on the Primary, i.e., it should return without having to wait for the data to be replicated.
What could be the possible reasons a write could take up so much time?