In WiredTiger, what are the default eviction targets and triggers, and what changes when the cache crosses each one?
answer
- who does the work changes
- background first, then your threads
- overall, dirty and updates
- eighty and ninety-five, five and twenty
basics
~20 sBy default, worker threads evict at 80% cache use or 5% dirty; application threads join at 95% use or 20% dirty. Updates carry their own pair, 2.5% and 10%. At 100% of the cache, operations stall.
solid answer
~40 sEach pair has a target, where background eviction worker threads act, and a trigger, where application threads must help before continuing. `eviction_target` is 80% and `eviction_trigger` 95% of the cache, and both count all content, clean and dirty. `eviction_dirty_target` is 5% and `eviction_dirty_trigger` 20%. Updates get half of each dirty value: 2.5% and 10%. All of them apply at "at least" that much. These are WiredTiger's own defaults; `mongod` passes only absolute overrides, and those only if you set them. Removing a clean page just frees memory; a dirty page must be reconciled and written first, which is why dirty pressure is the costly one. When application threads evict, the operation's latency includes that work. At 100% of the cache, operations stall.
go deeper
Recall the four headline numbers, 80 and 95 overall, 5 and 20 dirty, and that targets belong to background threads while triggers pull in application threads.
Explain why dirty eviction costs more, using reconciliation and the write to storage, and state that the overall pair counts all content, not clean pages alone.
Translate the percentages into gigabytes for the real cache size, and read a sustained trigger as a symptom of something upstream rather than a line to move.
Be wary of absolute overrides and undocumented parameters in a fleet: they stop scaling with the cache, outlive the incident that justified them, and surprise the next operator.
## What eviction is **Eviction** removes pages from WiredTiger's internal cache to keep it within limits. WiredTiger is MongoDB's storage engine, and the cache holds pages from collections and indexes. An eviction server walks the B-trees and queues the older candidates, and worker threads take pages from those queues and evict them. Two words carry the design: - A **target** is the level at which background worker threads act and the level WiredTiger tries to hold. - A **trigger** is the level at which **application threads**, the ones running your operations, must also do eviction before they can read or write more. That is deliberate throttling, and it shows up as latency. ## The defaults These are WiredTiger's defaults, from its configuration definitions. `mongod`'s config string does not pass `eviction_target` or `eviction_trigger` at all. The table shows the values on a 31.5 GB cache, the default for a 64 GB host. | Setting | What it measures | Default | On 31.5 GB | Who acts | |---|---|---|---|---| | `eviction_target` | all content | 80% | 25.2 GB | worker threads | | `eviction_trigger` | all content | 95% | about 29.9 GB | application threads too | | `eviction_dirty_target` | dirty content | 5% | about 1.6 GB | worker threads | | `eviction_dirty_trigger` | dirty content | 20% | 6.3 GB | application threads too | | `eviction_updates_target` | bytes of updates | 2.5%, half the dirty target | about 0.8 GB | worker threads | | `eviction_updates_trigger` | bytes of updates | 10%, half the dirty trigger | about 3.2 GB | application threads too | Read the edges carefully: - **Which side the exact value falls on.** The definitions say "at least this much", so reaching the value counts. - **The overall pair counts everything.** People often call 80% and 95% the "clean" thresholds, but they measure all content in the cache, clean and dirty together. - **Percentages follow the cache.** Double the cache and each threshold doubles in bytes, unless someone set an absolute override. - **100% is a separate limit.** WiredTiger's tuning guide says operations stall when the cache reaches 100% of its size. ## Why dirty costs more - **Clean** data is identical to the version on disk. To evict a clean page, WiredTiger frees its memory, and the page remains on disk unchanged. - **Dirty** data has been modified since it was read. To evict a dirty page, WiredTiger must first **reconcile** it, converting it from the in-memory to the on-disk format, and then write it to storage. So the pace of dirty eviction is bounded by the storage, and a write burst can outrun it. That explains why the dirty trigger sits far below the overall one, and why application threads doing dirty eviction see their latency tied to the storage's write speed. ## What changes at each level 1. **Below every target:** no eviction pressure. The cache can fill as pages are read. 2. **At a target:** worker threads evict in the background. Operations usually do not notice. 3. **At a trigger:** application threads are also tasked with eviction. Tail latency rises first, because some operations do the extra work and others do not. 4. **At 100% of the cache:** operations stall until space is made. The overall, dirty and updates pairs are watched independently. A cache can sit at a comfortable 60% overall and still pull application threads into eviction, because dirty content has reached 20%. The reverse also happens: a read-heavy workload with hardly any dirty data can reach 95%. ## What MongoDB lets you change - **Worker threads:** `wiredTigerEvictionThreadsMin` and `wiredTigerEvictionThreadsMax` both default to 4, range from 1 to 64 and can be changed at runtime. These `mongod` defaults, not WiredTiger's own, are what a server uses. - **Absolute overrides:** `wiredTigerEvictionDirtyTargetGB`, `wiredTigerEvictionDirtyMaxGB` and `wiredTigerEvictionUpdatesMaxGB` are startup parameters in the source, default to 0 and are passed to WiredTiger only when set. The 9.0 manual's parameter reference does not list them, so treat them as support-level tools. Absolute values also do not grow when the cache does. - **`wiredTigerEngineRuntimeConfig`** can pass settings to a running engine, and the manual warns to leave it alone unless MongoDB engineers direct you. Tuning these numbers is rarely the first answer. If dirty content keeps reaching 20%, the question is usually why writes outrun the storage, not where the line sits.
- Why are the WiredTiger dirty thresholds so much lower than the overall ones?A dirty page has to be reconciled and written before its memory can be reclaimed, so it cannot be freed quickly under pressure, while a clean page can be dropped at once. WiredTiger's tuning guide adds that dirty limits bound the work a checkpoint has to do in the worst case and limit memory fragmentation.
- If WiredTiger cache usage sits at 95%, is that automatically a problem?Sitting at 80% is normal, since that is the level WiredTiger aims to hold. At 95% application threads start evicting, and the tuning guide says usage tends to stay at this level when pressure exceeds what workers can handle. So 95% sustained is a sign of pressure; judge it with latency and the application-thread counters.
- Do MongoDB's eviction thread parameters use WiredTiger's defaults?No. `mongod` passes its own `threads_min` and `threads_max` in the config string, from `wiredTigerEvictionThreadsMin` and `wiredTigerEvictionThreadsMax`, both defaulting to 4 at 9.0.4. Quote the server parameters for a MongoDB deployment rather than the engine's own defaults, because the owner of the number is `mongod`.
- The 80% and 95% thresholds apply only to clean pages.
- Eviction starts only when the WiredTiger cache is completely full.
- Application threads never do eviction; only background threads do.
- Evicting a dirty page is as cheap as evicting a clean one.
- Reaching the 5% dirty target makes application threads evict.