Skip to content
Curriculum Directory • 50 In-Depth Modules

Document Database Architecture Concepts

Master MongoDB internals from BSON byte layouts and WiredTiger cache eviction to ESR compound indexing, aggregation pipeline memory limits, and distributed Raft consensus.

TOPIC 01Beginner

BSON Binary Format & Wire Serialization

Binary JSON (BSON) is the lightweight, traversable, and efficient binary-encoded serialization format powering MongoDB storage and network IPC.

bson storageExplore Lesson
TOPIC 02Intermediate

16MB Document Boundary & Architecture Limits

MongoDB enforces a strict 16MB maximum BSON document size to safeguard RAM cache efficiency, network bandwidth, and prevent runaway document bloat.

bson storageExplore Lesson
TOPIC 03Intermediate

Field Name Storage Overhead & Compression

Because BSON stores field names in every document tuple, verbose field names directly amplify RAM cache usage and network serialization payloads.

bson storageExplore Lesson
TOPIC 04Intermediate

12-Byte ObjectId Anatomy & Generation Mechanics

MongoDB ObjectIds are 12-byte BSON identifiers engineered to be globally unique, distributed, and roughly monotonically ordered without central coordination.

bson storageExplore Lesson
TOPIC 05Intermediate

Data Modeling: Embedding vs Referencing (1:1, 1:N, N:N)

The fundamental architectural choice in MongoDB: embedding subdocuments for atomic, single-read access versus referencing documents to avoid duplication and bloat.

bson storageExplore Lesson
TOPIC 06Intermediate

Schema Validation via JSON Schema Validator

Enforce structural data contracts, data types, and required fields directly inside MongoDB engine using declarative JSON Schema validation rules.

bson storageExplore Lesson
TOPIC 07Intermediate

Capped Collections & High-Throughput FIFO Queues

Capped collections are fixed-size circular storage queues that overwrite the oldest documents when allocated space is exhausted, guaranteeing natural insertion-order preservation.

bson storageExplore Lesson
TOPIC 08Intermediate

GridFS Binary Chunking Architecture

GridFS splits binary files exceeding the 16MB document boundary into standardized 255KB chunks across two collections: fs.files and fs.chunks.

bson storageExplore Lesson
TOPIC 09Intermediate

BSON Data Types: Decimal128, Int64, and UTC Dates

Master BSON numeric fidelity and temporal types, avoiding IEEE 754 floating point rounding corruption in financial systems using Decimal128.

bson storageExplore Lesson
TOPIC 10Advanced

MongoDB Schema Anti-Patterns & Pitfalls

Identify and remediate critical MongoDB anti-patterns: unbounded arrays, massive documents, premature indexing, and pure SQL-style normalization.

bson storageExplore Lesson
TOPIC 11Intermediate

WiredTiger B-Tree Internal vs Leaf Page Layout

WiredTiger structures both data collections and indexes as B-Trees, organizing data into Internal branch pages and Leaf data pages.

wiredtigerExplore Lesson
TOPIC 12Advanced

WiredTiger In-Memory Cache (Clean vs Dirty Pages)

The WiredTiger cache buffers frequently accessed B-Tree pages in memory, managing transitions between Clean and Dirty page states.

wiredtigerExplore Lesson
TOPIC 13Advanced

WiredTiger Checkpoints & Crash Consistency

WiredTiger periodically writes consistent filesystem snapshots (checkpoints) to disk every 60 seconds, acting as recovery anchors during crash reboots.

wiredtigerExplore Lesson
TOPIC 14Expert

The Lookaside Table (LAS) & Cache Pressure Overflow

The WiredTiger Lookaside Table (LAS) acts as an overflow swap area on disk for old transaction updates when the in-memory cache experiences extreme pressure.

wiredtigerExplore Lesson
TOPIC 15Advanced

WiredTiger MVCC & In-Memory Snapshot Isolation

WiredTiger implements multi-version concurrency control (MVCC) in memory using linked update chains, allowing readers to query consistent snapshots without blocking writers.

wiredtigerExplore Lesson
TOPIC 16Advanced

WiredTiger Journaling & fsync Durability Mechanics

The WiredTiger write-ahead journal logs raw data mutations sequentially to non-volatile disk, guaranteeing ACID durability between 60-second checkpoint intervals.

wiredtigerExplore Lesson
TOPIC 17Intermediate

Block Compression: Snappy, zlib, zstd & Prefix Compression

WiredTiger achieves 60-80% storage savings by compressing collection data blocks with Snappy/zstd and index pages with Prefix Compression.

wiredtigerExplore Lesson
TOPIC 18Advanced

Eviction Server Threads & Cache Eviction Triggers

WiredTiger utilizes autonomous background eviction worker threads to continuously reclaim cache memory, pacing clean page drops and dirty page flushes.

wiredtigerExplore Lesson
TOPIC 19Advanced

Concurrency Control: Read Tickets vs Write Tickets

MongoDB limits concurrent WiredTiger storage engine execution using Ticket Concurrency Control (128 read tickets and 128 write tickets by default).

wiredtigerExplore Lesson
TOPIC 20Advanced

MMAPv1 vs WiredTiger: The Storage Architecture Evolution

Analyze the architectural leap from MongoDB's legacy MMAPv1 engine (database-level locking, uncompressed) to WiredTiger (document-level concurrency, compression).

wiredtigerExplore Lesson
TOPIC 21Beginner

Single-Field Indexes & Sort Directionality

Single-field indexes create a sorted B-Tree on one document attribute. Sort directionality (1 vs -1) does not matter for single-field queries because WiredTiger traverses B-Trees bidirectionally.

indexingExplore Lesson
TOPIC 22Advanced

Compound Indexes & The ESR (Equality, Sort, Range) Rule

The Golden Rule of MongoDB Indexing: Order compound index attributes by Equality first, Sort second, and Range third to minimize scanned index keys.

indexingExplore Lesson
TOPIC 23Intermediate

Multikey Indexes on Arrays & Architecture Restrictions

When an index includes an array field, MongoDB creates a Multikey index where each array element receives its own B-Tree entry, introducing critical compound index constraints.

indexingExplore Lesson
TOPIC 24Advanced

Covered Queries & Zero-Document Heap Scans

A Covered Query is the fastest possible read in MongoDB: every queried and projected field exists within the index B-Tree, completely bypassing document heap reads.

indexingExplore Lesson
TOPIC 25Intermediate

Partial & Sparse Indexes: Saving RAM on Skewed Data

Partial and Sparse indexes index only documents matching a filter expression or containing a target field, slashing index RAM footprint by up to 95%.

indexingExplore Lesson
TOPIC 26Intermediate

TTL (Time To Live) Indexes & Automated Document Expiry

TTL indexes automatically purge documents from collections after a designated time interval based on a date timestamp field, replacing custom cron cleanup jobs.

indexingExplore Lesson
TOPIC 27Advanced

Text Indexes & Wildcard ($**) Index Architectures

Text indexes provide tokenization and stemming for keyword search, while Wildcard indexes ($**) index arbitrary, dynamic document schemas and polymorphic attributes.

indexingExplore Lesson
TOPIC 28Intermediate

Geospatial 2dsphere Indexes & GeoJSON Spatial Queries

The 2dsphere index calculates spherical geometries on Earth’s curved surface using GeoJSON objects, powering proximity, polygon containment, and intersection queries.

indexingExplore Lesson
TOPIC 29Intermediate

Hidden Indexes: Evaluating Index Dropping Safely

Hidden indexes allow database administrators to hide an index from the query planner to safely test the impact of index removal before permanently dropping it.

indexingExplore Lesson
TOPIC 30Advanced

Mastering explain("executionStats"): COLLSCAN vs IXSCAN

Analyze MongoDB query execution plans: diagnose full collection scans (COLLSCAN), index seeks (IXSCAN), in-memory sorts (SORT), and selectivity ratios.

indexingExplore Lesson
TOPIC 31Intermediate

Aggregation Pipeline Architecture & Streaming vs Blocking Stages

The MongoDB Aggregation Framework processes documents through an assembly-line sequence of stages, categorizing stages into non-blocking Streaming stages and memory-blocking Accumulator stages.

aggregationExplore Lesson
TOPIC 32Intermediate

$match Stage Placement & Early Filter Pushdown

Placing $match as the first stage in an aggregation pipeline enables index utilization (IXSCAN) and filters out non-matching documents before downstream processing.

aggregationExplore Lesson
TOPIC 33Intermediate

$group Mechanics, Hash Tables & Accumulator Operators

The $group stage partitions documents into discrete buckets by an _id expression and computes aggregate metrics using mathematical and array accumulators.

aggregationExplore Lesson
TOPIC 34Beginner

Document Reshaping: $project vs $addFields vs $set

Compare document transformation stages: $project selects and renames explicit fields, while $addFields and $set append computed values while preserving all existing document attributes.

aggregationExplore Lesson
TOPIC 35Intermediate

$unwind Array Flattening & Memory Multiplication

The $unwind stage deconstructs an array field from input documents, outputting one document for every element in the array.

aggregationExplore Lesson
TOPIC 36Advanced

$lookup Joins: Equi-Join vs Correlated Pipeline Joins

Perform relational Left Outer Joins in MongoDB using $lookup: from standard equi-joins to complex correlated subquery pipelines with nested filtering.

aggregationExplore Lesson
TOPIC 37Advanced

$facet Multi-Faceted Aggregation & Parallel Analytics

The $facet stage executes multiple independent aggregation sub-pipelines in parallel over the same input document stream in a single database query.

aggregationExplore Lesson
TOPIC 38Intermediate

$bucket and $bucketAuto: Histogram Categorization

Categorize numeric and temporal data into discrete histogram buckets using manual boundary ranges ($bucket) or automated equal-frequency percentiles ($bucketAuto).

aggregationExplore Lesson
TOPIC 39Advanced

Materialized Views via $merge and $out

Persist complex aggregation transformations into concrete physical collections using $out (destructive overwrite) or $merge (incremental upsert updates).

aggregationExplore Lesson
TOPIC 40Advanced

The 100MB RAM Stage Limit & allowDiskUse: true

Aggregation pipeline stages are constrained by a strict 100MB in-memory RAM limit; learn how to diagnose memory spillover and utilize allowDiskUse: true safely.

aggregationExplore Lesson
TOPIC 41Intermediate

Replica Set Topology: Primary, Secondary & Arbiter Nodes

A MongoDB Replica Set is an automated high-availability cluster consisting of one Primary node that accepts all writes and multiple Secondary nodes that replicate data.

distributedExplore Lesson
TOPIC 42Advanced

Raft-like Election Algorithm & Term Succession

MongoDB utilizes a consensus election protocol modeled on Raft (election terms, heartbeat timeouts, and strict majority voting) to elect a primary in under 3 seconds.

distributedExplore Lesson
TOPIC 43Advanced

The Replication Oplog & Resolving Replication Lag

The Oplog (operations log) is a capped collection recording idempotent state modifications; monitor and resolve replication lag to avoid stale reads and failover rollbacks.

distributedExplore Lesson
TOPIC 44Advanced

Write Concerns: w:1 vs w:majority vs j:true vs wtimeout

Write Concerns govern the level of acknowledgment requested from MongoDB before confirming a write operation: balancing latency against durability and rollback protection.

distributedExplore Lesson
TOPIC 45Advanced

Read Concerns: local vs majority vs linearizable vs snapshot

Read Concerns control the consistency and isolation of data read from MongoDB: from fast uncommitted local reads to strictly serializable linearizable queries.

distributedExplore Lesson
TOPIC 46Intermediate

Read Preferences: primary vs secondaryPreferred vs nearest

Read Preferences dictate how database client drivers route read operations across members of a replica set: balancing read scalability against data staleness.

distributedExplore Lesson
TOPIC 47Expert

Causal Consistency Sessions & Logical Clocks

Causal Consistency client sessions utilize Lamport logical clocks (ClusterTime) to guarantee Read-Your-Own-Writes consistency even when reading from lagging secondaries.

distributedExplore Lesson
TOPIC 48Advanced

Sharding Architecture: mongos, Config Servers & Shards

MongoDB horizontally partitions massive collections across multiple independent physical clusters (Shards) coordinated by query routers (mongos) and metadata catalogs (Config Servers).

distributedExplore Lesson
TOPIC 49Expert

Shard Key Selection: Cardinality, Monotonic Traps & Jumbo Chunks

The Shard Key is the single most critical architectural choice in MongoDB: evaluate High Cardinality, High Frequency, and Non-Monotonic criteria to avoid un-splittable Jumbo Chunks and write hot spots.

distributedExplore Lesson
TOPIC 50Expert

Multi-Document ACID Transactions & Distributed Two-Phase Commit

MongoDB provides fully compliant multi-document ACID transactions across replica sets and sharded clusters using snapshot isolation and distributed Two-Phase Commit (2PC).

distributedExplore Lesson