Course contentsShow
← System Design
Lesson 400 of 1,91911. NoSQL: Document StoresFree lesson

Storage Engines: WiredTiger

How MongoDB's WiredTiger engine provides compression, document-level locking, and checkpoint-based durability.

Storage Engines: WiredTiger

What You'll Learn

You'll learn how MongoDB's WiredTiger storage engine delivers efficient data storage through compression, fine-grained locking, and crash recovery.

What Is a Storage Engine?

A storage engine is the underlying component that manages how data is physically written to and read from disk. Think of it as the warehouse manager that decides how to pack, organize, and retrieve boxes (your documents).

MongoDB uses WiredTiger as its default storage engine since version 3.2, replacing the older MMAPv1 engine.

Three Core Features of WiredTiger

1. Compression

WiredTiger compresses data both in memory and on disk using algorithms like Snappy (default) or zlib. This means your 1 GB of documents might only consume 300-400 MB of actual storage—like vacuum-sealing clothes to save closet space.

2. Document-Level Locking

Instead of locking entire collections during writes (like locking a whole warehouse when moving one box), WiredTiger locks individual documents. This allows multiple write operations to happen simultaneously on different documents in the same collection, dramatically improving concurrency.

3. Checkpoint-Based Durability

WiredTiger writes data changes to memory first, then periodically creates checkpoints—consistent snapshots written to disk every 60 seconds by default. Between checkpoints, it maintains a write-ahead log (journal) to recover any changes if MongoDB crashes. It's like saving a video game: checkpoints are your auto-saves, and the journal captures everything since the last save.

Why This Matters

WiredTiger balances performance and safety. Compression saves storage costs. Document-level locking means your application can handle more concurrent users. Checkpoints ensure you don't lose data even during unexpected shutdowns.

Key Takeaway: WiredTiger provides MongoDB with compression for storage efficiency, document-level locking for high concurrency, and checkpoint-based durability for reliable crash recovery.