What Is WiredTiger in MongoDB?
Learn what WiredTiger is, MongoDB's default storage engine, how its document-level locking, caching, journaling, and compression improve performance.
Expected Interview Answer
WiredTiger is MongoDB's default storage engine, responsible for how data and indexes are actually written to disk, cached in memory, and made durable, including document-level concurrency control and native compression.
Before WiredTiger became the default in MongoDB 3.2, MongoDB used MMAPv1, which only supported collection-level locking and no built-in compression. WiredTiger replaced that with document-level concurrency control, meaning many clients can write to different documents in the same collection simultaneously without blocking each other. It maintains an in-memory cache (by default about 50% of RAM minus 1GB) for hot data, uses a write-ahead journal for crash recovery, and performs periodic checkpoints to flush a consistent snapshot to disk. It also supports on-disk compression algorithms like snappy and zlib, which shrinks storage footprint significantly compared to the older engine.
- Document-level locking dramatically improves write concurrency
- Built-in compression reduces disk usage and I/O
- Checkpointing plus journaling gives strong crash-recovery guarantees
- Configurable cache sizing tunes memory usage for the workload
- Powers both replica sets and sharded clusters transparently
AI Mentor Explanation
WiredTiger is like a stadium's modern turnstile system that lets fans enter through many separate gates at once instead of funneling everyone through one narrow gate. Each turnstile handles its own queue independently, so thousands of spectators get checked in at the same time without one slow gate blocking everyone, mirroring document-level locking.
Step-by-Step Explanation
Step 1
Default storage engine
WiredTiger has been MongoDB's default storage engine since version 3.2, replacing the older MMAPv1 engine.
Step 2
Document-level concurrency
Writes lock only the specific document being modified, not the whole collection, allowing far higher write concurrency.
Step 3
In-memory cache
WiredTiger keeps frequently accessed data and indexes in a configurable cache, defaulting to roughly 50% of RAM minus 1GB.
Step 4
Journaling and checkpoints
A write-ahead journal records operations for crash recovery, while periodic checkpoints flush a consistent snapshot to disk.
Step 5
Native compression
Data and indexes are compressed on disk using algorithms like snappy (default) or zlib, reducing storage footprint and I/O.
What Interviewer Expects
- Knows WiredTiger is the default storage engine since MongoDB 3.2
- Understands document-level locking versus MMAPv1's collection-level locking
- Can explain the role of the cache, journal, and checkpoints
- Mentions compression as a WiredTiger benefit
- Aware that storage engine choice affects performance and hardware sizing
Common Mistakes
- Thinking MongoDB has no real storage engine abstraction
- Confusing WiredTiger's cache with the operating system's file system cache
- Believing WiredTiger still uses collection-level locks like MMAPv1
- Assuming compression is optional or must be configured manually to enable
Best Answer (HR Friendly)
“WiredTiger is the technology inside MongoDB that manages how data is actually stored, cached, and compressed on disk. It lets many operations happen at the same time efficiently and keeps data safe if the server crashes, which is a big part of why modern MongoDB performs well at scale.”
Code Example
// Check current storage engine
db.serverStatus().storageEngine
// { name: 'wiredTiger', ... }
// View WiredTiger cache stats
db.serverStatus().wiredTiger.cache['bytes currently in the cache']
// Set cache size via mongod.conf
// storage:
// wiredTiger:
// engineConfig:
// cacheSizeGB: 4Follow-up Questions
- How does WiredTiger's document-level locking differ from MMAPv1's collection-level locking?
- What is the purpose of the journal in WiredTiger?
- How would you size the WiredTiger cache for a production deployment?
- What compression options does WiredTiger support and what are the tradeoffs?
- How do checkpoints interact with crash recovery in WiredTiger?
MCQ Practice
1. Since which MongoDB version has WiredTiger been the default storage engine?
WiredTiger became the default storage engine in MongoDB 3.2, replacing MMAPv1.
2. What locking granularity does WiredTiger use for writes?
WiredTiger locks at the document level, allowing many concurrent writes to different documents in the same collection.
3. Which feature does WiredTiger provide that MMAPv1 lacked?
WiredTiger natively supports compression (snappy by default, or zlib/zstd), which MMAPv1 did not offer.
Flash Cards
What is WiredTiger? — MongoDB's default storage engine that handles on-disk storage, caching, compression, and concurrency control.
What locking model does WiredTiger use? — Document-level locking, allowing high write concurrency compared to the older collection-level MMAPv1 engine.
How does WiredTiger recover from a crash? — Via a write-ahead journal combined with periodic checkpoints that flush consistent snapshots to disk.
What compression does WiredTiger use by default? — Snappy compression for collection data, with zlib and zstd available as alternatives.