MongoDB 使用 150 MB 内存是否理想?
这是我使用 MongoDB 的第一个项目。
我已将其托管在 linode(使用 XEN 的 VPS)上,并且我正在使用“top”检查内存使用情况。
mongod 进程似乎使用了大约 150 MB 的内存。我检查时没有发现任何联系。我使用 RockMongo 来管理它。我的主要数据库统计数据是 -
Size - 464m
Storage Size - 83.99m
Data Size - 66.4m
Index Size - 49.33m
Collections - 5
Objects - 584850
当 cron 作业运行时会发生很多查询,大约每分钟 75 个甚至更多。但是,正如我之前所说,当我检查内存使用情况时,没有任何连接。
db.serverStatus();
的输出
注意 - 我在运行 db.serverStatus();
之前重新启动了 mongod,内存使用量为 40 MB。
{
"retval": {
"version": "1.6.5",
"uptime": 790,
"uptimeEstimate": 783,
"localTime": "Mon, 07 Feb 2011 00: 51: 04 -0500",
"globalLock": {
"totalTime": 790027671,
"lockTime": 376381,
"ratio": 0.00047641495838188,
"currentQueue": {
"total": 0,
"readers": 0,
"writers": 0
}
},
"mem": {
"bits": 64,
"resident": 38,
"virtual": 957,
"supported": true,
"mapped": 288
},
"connections": {
"current": 2,
"available": 9598
},
"extra_info": {
"note": "fields vary by platform",
"heap_usage_bytes": 152448,
"page_faults": 0
},
"indexCounters": {
"btree": {
"accesses": 1,
"hits": 1,
"misses": 0,
"resets": 0,
"missRatio": 0
}
},
"backgroundFlushing": {
"flushes": 13,
"total_ms": 1,
"average_ms": 0.076923076923077,
"last_ms": 0,
"last_finished": "Mon, 07 Feb 2011 00: 50: 54 -0500"
},
"cursors": {
"totalOpen": 0,
"clientCursors_size": 0,
"timedOut": 0
},
"opcounters": {
"insert": 0,
"query": 57,
"update": 0,
"delete": 0,
"getmore": 0,
"command": 46
},
"asserts": {
"regular": 0,
"warning": 0,
"msg": 0,
"user": 0,
"rollovers": 0
},
"ok": 1
},
"ok": 1
}
我的一个朋友在具有相同内存量 (1024 MB) 的 linode 上运行他的 WordPress 博客。他的 MySQL 使用率仅为 20.48 左右。 12 位用户喜欢在他的网站上“永远冲浪”(如always-on)。
这让我觉得 MongoDB 对我来说不是一个好的选择,我应该坚持使用 MySQL!
谢谢大家。
This is the first project by me which is using MongoDB.
I have hosted it on a linode (a VPS which uses XEN) and I'm checking memory usage with "top".
The mongod process seem to use around 150 MB of memory. There were no connections to it when I checked. I use RockMongo to administer it. My main database stats are -
Size - 464m
Storage Size - 83.99m
Data Size - 66.4m
Index Size - 49.33m
Collections - 5
Objects - 584850
A lot of queries happen when the cron job is running, around 75 per minute or even more. But, as I said earlier, when I checked the memory usage, there were no connections.
Output of db.serverStatus();
Note - I had restarted mongod before running db.serverStatus();
and the memory usage was 40 MB.
{
"retval": {
"version": "1.6.5",
"uptime": 790,
"uptimeEstimate": 783,
"localTime": "Mon, 07 Feb 2011 00: 51: 04 -0500",
"globalLock": {
"totalTime": 790027671,
"lockTime": 376381,
"ratio": 0.00047641495838188,
"currentQueue": {
"total": 0,
"readers": 0,
"writers": 0
}
},
"mem": {
"bits": 64,
"resident": 38,
"virtual": 957,
"supported": true,
"mapped": 288
},
"connections": {
"current": 2,
"available": 9598
},
"extra_info": {
"note": "fields vary by platform",
"heap_usage_bytes": 152448,
"page_faults": 0
},
"indexCounters": {
"btree": {
"accesses": 1,
"hits": 1,
"misses": 0,
"resets": 0,
"missRatio": 0
}
},
"backgroundFlushing": {
"flushes": 13,
"total_ms": 1,
"average_ms": 0.076923076923077,
"last_ms": 0,
"last_finished": "Mon, 07 Feb 2011 00: 50: 54 -0500"
},
"cursors": {
"totalOpen": 0,
"clientCursors_size": 0,
"timedOut": 0
},
"opcounters": {
"insert": 0,
"query": 57,
"update": 0,
"delete": 0,
"getmore": 0,
"command": 46
},
"asserts": {
"regular": 0,
"warning": 0,
"msg": 0,
"user": 0,
"rollovers": 0
},
"ok": 1
},
"ok": 1
}
A friend of mine runs his WordPress blog on a linode with same amount of ram (1024 MB). His MySQL usage show mere 20.48 and approx. 12 users are like "always-surfing" (as in always-on) on his site.
This makes me feel MongoDB isn't a nice choice for me and I should have sticked to MySQL!
Thank you, all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“使用”那么多内存并不像看起来那么糟糕……MongoDB 将(至少看起来)用掉大量可用内存,但它让操作系统的 VMM 告诉它在什么时候释放内存需要。 (请参阅 MongoDB 文档中的缓存。)
在大多数情况下,它“使用”用于缓存的内存,这大大加快了速度。
您应该能够通过重新启动 MongoDB 来释放所有内存。
但是,在某种程度上,MongoDB 并没有真正主动“使用”内存...继续阅读这个anwser中有更多细节..
如何释放Mongodb使用的缓存?
"Using" that much memory isn't as bad as it seems ... MongoDB will (at least seem to) use up a lot of available memory, but it leaves it up to the OS's VMM to tell it to release the memory when need. (see Caching in the MongoDB docs.)
For the most part it's "using" that memory for cache, which dramatically speeds things up.
You should be able to release any and all memory by restarting MongoDB.
However, to some extent MongoDB isn't really actively "using" the memory ... read on for a lot more details in this anwser ..
How to release the caching which is used by Mongodb?
内存管理完全取决于操作系统。
阅读
http://blog.mongodb.org/post/101911655/mongo- db-memory-usage
目前基本上没有办法影响内存使用情况....并提到:了解内存映射文件,不要将内存映射文件的内存使用情况与实际情况混淆内存使用情况。
Memory management is soley up to the OS.
Read
http://blog.mongodb.org/post/101911655/mongo-db-memory-usage
There is basically no way right now to influence the memory usage....and mentioned: learn about memory-mapped files and don't mix up the memory usage of memory mapped files with the actual memory usage.