Sim*_*ini 4 ram limit mongodb docker
我有以下配置:
Redis 和 Mongodb 都用于存储海量数据。我知道 Redis 需要将所有数据保存在 RAM 中,我对此没有意见。不幸的是,Mongo 开始占用大量 RAM,一旦主机 RAM 已满(我们在这里谈论的是 32GB),Mongo 或 Redis 就会崩溃。
我已经阅读了以下有关此问题的先前问题:
it's completely okay to limit the WiredTiger cache size, since it handles I/O operations pretty efficientlyMongoDB uses the LRU (Least Recently Used) cache algorithm to determine which "pages" to release, you will find some more information in these two questionsMongoDB keeps what it can of the indexes in RAM. They'll be swaped out on an LRU basis. You'll often see documentation that suggests you should keep your "working set" in memory: if the portions of index you're actually accessing fit in memory, you'll be fine.现在我从所有这些答案中似乎明白的是:
考虑到这一点,我希望 Mongo 尝试使用尽可能多的 RAM 空间,但也能够以很少的 RAM 空间运行并从磁盘获取大部分内容。但是,我通过使用--memoryand限制了 Mongo Docker 容器的内存(例如 8GB),--memory-swap但不是从磁盘获取内容,Mongo 在内存不足时立即崩溃。
如何强制 Mongo 仅使用可用内存并从磁盘中获取不适合内存的所有内容?
感谢@AlexBlex 的评论,我解决了我的问题。显然,问题在于 Docker 将容器的 RAM 限制为,8GB但wiredTiger 存储引擎仍在尝试使用50% - 1GB总系统 RAM 用于其缓存(在我的情况下,这将是15 GB)。
通过使用此配置选项将wiredTiger 的缓存大小限制为小于Docker 分配的值解决了该问题。
| 归档时间: |
|
| 查看次数: |
7224 次 |
| 最近记录: |