Sim*_*ini 17 mongodb memory limits 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 仅使用可用内存并从磁盘中获取不适合内存的所有内容?
Md *_*han 11
根据 MongoDB BOL Here Changed in version 3.4: Values can range from 256MBto 10TBand can be a float. 此外,默认值也发生了变化。
从 开始3.4,默认情况下,WiredTiger内部缓存将使用较大者:
50% of RAM minus 1 GB, or
256 MB.
Run Code Online (Sandbox Code Playgroud)
有了WiredTiger,MongoDB 同时使用了WiredTiger internal cache和filesystem cache.
通过filesystem cache,MongoDB 自动使用所有未由WiredTiger cache或其他进程使用的空闲内存。
该storage.wiredTiger.engineConfig.cacheSizeGB限制的大小WiredTiger内部缓存。操作系统会将可用的空闲内存用于文件系统缓存,这允许压缩的 MongoDB 数据文件保留在内存中。此外,operating system将使用任何空闲 RAM 来缓冲文件系统块和文件系统缓存。
为了容纳额外的RAM使用者,您可能必须减少WiredTiger内部缓存大小。
进一步参考WiredTiger 存储引擎和配置文件选项
小智 6
实际上,如果您仔细观察,并不是 mongod 因“内存不足”而死亡,而是内核 OOM(内存不足)管理器杀死了 mongod,因为它具有最大的内存使用量。
可以,你可以尝试用monngodb配置参数cacheSizeGB来解决问题,但是在容器环境下,最好使用cgroups来限制你的三个容器中的任何一个获取的资源。
| 归档时间: |
|
| 查看次数: |
17127 次 |
| 最近记录: |