我们第一次使用mongodb时遇到了一些问题:)以下是一些事实:
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system-- usr sys idl wai hiq siq| read writ| recv send| in out | int csw 46 1 53 0 0 0| 0 4096B| 42k 19k| 0 0 | 317 5328 48 1 52 0 0 1| 0 92k| 46k 7590B| 0 0 | 321 5308 50 2 48 0 0 0| 0 0 | 39k 7218B| 0 0 | 304 5359 47 1 51 0 0 1| 0 0 | 47k 10k| 0 0 | 332 5679 46 1 52 0 0 0| 0 0 | 44k 15k| 0 0 | 319 5099
insert query update delete getmore command flushes mapped vsize res faults locked % idx miss % qr|qw ar|aw netIn netOut conn repl time 0 0 0 0 0 1 0 1.41g 8.39g 242m 0 96.2 0 0|3280 1|5322 62b 1k 5324 M 21:11:50 0 0 0 0 0 1 0 1.41g 8.39g 242m 0 96.5 0 0|3204 1|5322 62b 1k 5324 M 21:11:51 0 0 0 0 0 1 0 1.41g 8.39g 242m 0 96 0 1|3351 1|5322 62b 1k 5324 M 21:11:52 0 0 1 0 0 1 0 1.41g 8.39g 242m 0 96.9 0 0|3251 1|5322 485b 1k 5324 M 21:11:53 0 0 0 0 1 1 0 1.41g 8.39g 242m 0 95.6 0 0|3280 1|5322 112b 1k 5324 M 21:11:54
{ "host" : "foo001", "version" : "2.0.2", "process" : "mongod", "uptime" : 21370, "uptimeEstimate" : 18626, "localTime" : ISODate("2012-02-23T20:20:59.589Z"), "globalLock" : { "totalTime" : 21369761258, "lockTime" : 19450568051, "ratio" : 0.9101911722911022, "currentQueue" : { "total" : 3570, "readers" : 0, "writers" : 3570 }, "activeClients" : { "total" : 5500, "readers" : 1, "writers" : 5499 } }, "mem" : { "bits" : 64, "resident" : 255, "virtual" : 8782, "supported" : true, "mapped" : 1440, "mappedWithJournal" : 2880 }, "connections" : { "current" : 5501, "available" : 4099 }, "extra_info" : { "note" : "fields vary by platform", "heap_usage_bytes" : 81930736, "page_faults" : 2916 }, "indexCounters" : { "btree" : { "accesses" : 2377, "hits" : 2377, "misses" : 0, "resets" : 0, "missRatio" : 0 } }, "backgroundFlushing" : { "flushes" : 356, "total_ms" : 2372, "average_ms" : 6.662921348314606, "last_ms" : 0, "last_finished" : ISODate("2012-02-23T20:20:56.446Z") }, "cursors" : { "totalOpen" : 5500, "clientCursors_size" : 5500, "timedOut" : 0, "totalNoTimeout" : 5499 }, "network" : { "bytesIn" : 51373772, "bytesOut" : 51176411, "numRequests" : 176017 }, "repl" : { "ismaster" : true }, "opcounters" : { "insert" : 0, "query" : 25, "update" : 142157, "delete" : 0, "getmore" : 39053, "command" : 284 }, "asserts" : { "regular" : 0, "warning" : 0, "msg" : 0, "user" : 0, "rollovers" : 0 }, "writeBacksQueued" : false, "dur" : { "commits" : 19, "journaledMB" : 0, "writeToDataFilesMB" : 0, "compression" : 0, "commitsInWriteLock" : 0, "earlyCommits" : 0, "timeMs" : { "dt" : 3083, "prepLogBuffer" : 0, "writeToJournal" : 0, "writeToDataFiles" : 0, "remapPrivateView" : 0 } }, "ok" : 1 }
{ "db" : "mydb", "collections" : 6, "objects" : 119174, "avgObjSize" : 323.99872455401345, "dataSize" : 38612224, "storageSize" : 57286656, "numExtents" : 26, "indexes" : 4, "indexSize" : 3899952, "fileSize" : 469762048, "nsSizeMB" : 16, "ok" : 1 }
任何提示?
此致
d
PS:我也将其交叉发布到mongo-user
答案 0 :(得分:5)
请,请不要将NFS用作数据库后端。有很多问题,特别是带锁定,而特别是带有NFS< V4。由于它们不仅仅是 性能问题,因此甚至可能不会考虑NFS。
我首先将我的数据库移动到本地磁盘,看看是否能解决性能问题 - 我怀疑它会...
修改强>
MongoDB人seem to agree,即使有点简洁,但
答案 1 :(得分:4)
根据mongostat结果,你正在排队写入(检查qr | qw,第二个值是高并且上升),这意味着你的系统在新写入之前写入速度不够快。
根据你的mongostat,写的数量不多,但每个都很慢。看起来问题是更新。你使用的是findAndModify吗?如果您使用复杂查询,那将会锁定数据库一段时间。 或许你在mongostat上发布的信息是在大量写入之后。无论如何,它们可能非常慢,或者你不会看到高锁(并且排队的写入会迅速减少)
您应该激活数据库分析器并分析您的更新。查看this page了解详情
PD:索引的大小看起来很好:
"indexes" : 4,
"indexSize" : 3899952,
那不到4 MB
EDITED:另一个细节,看起来有很多写客户端同时连接。如果有20个Web服务器,可能每个都连接多次。
"activeClients" : {
"total" : 5500,
"readers" : 1,
"writers" : 5499
}