【问题标题】:MongoDb/GridFs (C# driver) : WiredTiger caching problem/questionsMongoDb/GridFs(C# 驱动程序):WiredTiger 缓存问题/问题
【发布时间】:2020-07-17 15:44:40
【问题描述】:

我最近一直在使用 GridFs(C# 驱动程序)进行测试,并遇到了一个问题,在上传大约 100k 个文件后,每个文件的权重约为 1.5mb(有些是 50mb+,有些是 ~200kb):Mongodb 服务器的内存消耗上升了到 ~6.5Gb 和 ~6Gb 仅用于有线老虎缓存(db.serverstatus().wiredTiger.cache.bytes 当前在缓存中)。另一个问题是,在从 fs.files 和 fs.chunks 中删除所有文档并重新启动服务器后,有线 Tiger 缓存仍然是 ~6Gb,这导致进程坚持到 6.5Gb RAM。

我的问题是:

  • 这种缓存大小是否通常用于这个数量的文件?
  • 有线老虎如何/何时清空/驱逐它的缓存?
  • 有什么方法可以在不影响性能的情况下对其进行调整?

规格:MongoDb 服务器 4.2(未配置 storage.wiredTiger.engineConfig.cacheSizeGB),C#/GridFs 驱动程序 2.9,Windows 10(16Gb RAM)

非常感谢!

"cache" : {
        "application threads page read from disk to cache count" : 11456,
        "application threads page read from disk to cache time (usecs)" : 3922601,
        "application threads page write from cache to disk count" : 49,
        "application threads page write from cache to disk time (usecs)" : 6539,
        "bytes belonging to page images in the cache" : 6314172728.0,
        "bytes belonging to the cache overflow table in the cache" : 182,
        "bytes currently in the cache" : 6315679556.0,
        "bytes dirty in the cache cumulative" : 475772,
        "bytes not belonging to page images in the cache" : 1506827,
        "bytes read into cache" : 9863425672.0,
        "bytes written from cache" : 399800,
        "cache overflow cursor application thread wait time (usecs)" : 0,
        "cache overflow cursor internal thread wait time (usecs)" : 0,
        "cache overflow score" : 0,
        "cache overflow table entries" : 0,
        "cache overflow table insert calls" : 0,
        "cache overflow table max on-disk size" : 0,
        "cache overflow table on-disk size" : 0,
        "cache overflow table remove calls" : 0,
        "checkpoint blocked page eviction" : 0,
        "eviction calls to get a page" : 5335,
        "eviction calls to get a page found queue empty" : 56,
        "eviction calls to get a page found queue empty after locking" : 105,
        "eviction currently operating in aggressive mode" : 0,
        "eviction empty score" : 0,
        "eviction passes of a file" : 112,
        "eviction server candidate queue empty when topping up" : 25,
        "eviction server candidate queue not empty when topping up" : 87,
        "eviction server evicting pages" : 0,
        "eviction server slept, because we did not make progress with eviction" : 468,
        "eviction server unable to reach eviction goal" : 0,
        "eviction server waiting for a leaf page" : 25876,
        "eviction state" : 128,
        "eviction walk target pages histogram - 0-9" : 0,
        "eviction walk target pages histogram - 10-31" : 0,
        "eviction walk target pages histogram - 128 and higher" : 0,
        "eviction walk target pages histogram - 32-63" : 0,
        "eviction walk target pages histogram - 64-128" : 112,
        "eviction walk target strategy both clean and dirty pages" : 0,
        "eviction walk target strategy only clean pages" : 112,
        "eviction walk target strategy only dirty pages" : 0,
        "eviction walks abandoned" : 6,
        "eviction walks gave up because they restarted their walk twice" : 0,
        "eviction walks gave up because they saw too many pages and found no candidates" : 0,
        "eviction walks gave up because they saw too many pages and found too few candidates" : 0,
        "eviction walks reached end of tree" : 6,
        "eviction walks started from root of tree" : 6,
        "eviction walks started from saved location in tree" : 106,
        "eviction worker thread active" : 4,
        "eviction worker thread created" : 0,
        "eviction worker thread evicting pages" : 5177,
        "eviction worker thread removed" : 0,
        "eviction worker thread stable number" : 0,
        "files with active eviction walks" : 0,
        "files with new eviction walks started" : 6,
        "force re-tuning of eviction workers once in a while" : 0,
        "forced eviction - pages evicted that were clean count" : 0,
        "forced eviction - pages evicted that were clean time (usecs)" : 0,
        "forced eviction - pages evicted that were dirty count" : 0,
        "forced eviction - pages evicted that were dirty time (usecs)" : 0,
        "forced eviction - pages selected because of too many deleted items count" : 0,
        "forced eviction - pages selected count" : 0,
        "forced eviction - pages selected unable to be evicted count" : 0,
        "forced eviction - pages selected unable to be evicted time" : 0,
        "hazard pointer blocked page eviction" : 0,
        "hazard pointer check calls" : 5173,
        "hazard pointer check entries walked" : 27762,
        "hazard pointer maximum array length" : 3,
        "in-memory page passed criteria to be split" : 0,
        "in-memory page splits" : 0,
        "internal pages evicted" : 0,
        "internal pages queued for eviction" : 0,
        "internal pages seen by eviction walk" : 246,
        "internal pages seen by eviction walk that are already queued" : 0,
        "internal pages split during eviction" : 0,
        "leaf pages split during eviction" : 0,
        "maximum bytes configured" : 7990149120.0,
        "maximum page size at eviction" : 0,
        "modified pages evicted" : 0,
        "modified pages evicted by application threads" : 0,
        "operations timed out waiting for space in cache" : 0,
        "overflow pages read into cache" : 0,
        "page split during eviction deepened the tree" : 0,
        "page written requiring cache overflow records" : 0,
        "pages currently held in the cache" : 6306,
        "pages evicted by application threads" : 2,
        "pages queued for eviction" : 11200,
        "pages queued for eviction post lru sorting" : 10953,
        "pages queued for urgent eviction" : 704,
        "pages queued for urgent eviction during walk" : 0,
        "pages read into cache" : 11478,
        "pages read into cache after truncate" : 2,
        "pages read into cache after truncate in prepare state" : 0,
        "pages read into cache requiring cache overflow entries" : 0,
        "pages read into cache requiring cache overflow for checkpoint" : 0,
        "pages read into cache skipping older cache overflow entries" : 0,
        "pages read into cache with skipped cache overflow entries needed later" : 0,
        "pages read into cache with skipped cache overflow entries needed later by checkpoint" : 0,
        "pages requested from the cache" : 14583,
        "pages seen by eviction walk" : 13301,
        "pages seen by eviction walk that are already queued" : 1855,
        "pages selected for eviction unable to be evicted" : 4,
        "pages selected for eviction unable to be evicted as the parent page has overflow items" : 0,
        "pages selected for eviction unable to be evicted because of active children on an internal page" : 4,
        "pages selected for eviction unable to be evicted because of failure in reconciliation" : 0,
        "pages selected for eviction unable to be evicted due to newer modifications on a clean page" : 0,
        "pages walked for eviction" : 24882,
        "pages written from cache" : 52,
        "pages written requiring in-memory restoration" : 0,
        "percentage overhead" : 8,
        "tracked bytes belonging to internal pages in the cache" : 1000672,
        "tracked bytes belonging to leaf pages in the cache" : 6314678884.0,
        "tracked dirty bytes in the cache" : 120312,
        "tracked dirty pages in the cache" : 7,
        "unmodified pages evicted" : 5175
    },

【问题讨论】:

    标签: mongodb gridfs wiredtiger


    【解决方案1】:

    数据库将使用机器上的可用内存。

    您的统计数据显示 mongodb 使用的内存不到一半,这反映了 MongoDB 文档。

    有线老虎缓存大小有多种可用的旋钮。

    【讨论】:

    • 感谢您的回答。删除文档后缓存数据还保留正常吗?
    • 取决于缓存的具体内容,如果您没有压缩数据库,空间仍会分配给您拥有的数据。
    • 在生产机器上,您是否建议将有线 Tiger 缓存大小设置为高于默认值(比如总 RAM 的 80%)?
    • 取决于相关机器、工作负载等。您希望数据库使用可用内存。
    • 好吧,我这么说是因为 mongodb 官方文档说“避免将 WiredTiger 内部缓存大小增加到默认值以上”,默认值为(RAM - 1 GB)的 50%
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多