MongoDB & NoSQL (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
What is the MongoDB Journal and Checkpoints?
senior LevelCode ExampleSystem DesignDatabases & SQL
In Simple Words:
- Journal (Write-Ahead Log): Sequential on-disk log recording all write operations before applying them to data files. Fsynced to disk every 100ms. Guarantees crash recovery without data loss.
- Checkpoints: Every 60 seconds (or when journal exceeds 2 GB), WiredTiger takes a consistent snapshot of data in memory and flushes all dirty pages to the physical data files on disk.
text
WiredTiger Write Path:
Client Write ──► WiredTiger In-Memory Cache (RAM)
│
┌───────────┴───────────┐
▼ ▼
Journal Log (Fsync: 100ms) Checkpoint to Disk (Every 60s)
(Guarantees Durability) (Flushes all dirty data pages)