MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
JSON vs BSON Data Types & MongoDB Internal Storage Engine (WiredTiger)0%
Study Materials
MongoDB & MongooseProgress 0%
1.1Document Databases vs Relational SQL: CAP Theorem & When to Use NoSQL1.2JSON vs BSON Data Types & MongoDB Internal Storage Engine (WiredTiger)1.3MongoDB Atlas Cloud Setup, Network Whitelisting & Compass GUI
HomeTutorialsMongoDB & MongooseJSON vs BSON Data Types & MongoDB Internal Storage Engine (WiredTiger)
MongoDB Atlas Cloud Setup, Network Whitelisting & Compass GUI

JSON vs BSON Data Types & MongoDB Internal Storage Engine (WiredTiger)

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

While developers query MongoDB using familiar JavaScript/JSON notation, the database internally serializes and stores documents as BSON (Binary JSON). Behind the scenes, the WiredTiger storage engine delivers enterprise-grade performance, in-memory caching, and transparent disk compression.


1. Why Not Pure JSON? (JSON vs BSON)

Plain JSON (JavaScript Object Notation) is a lightweight text-based format, but it has severe limitations for a production database:

  1. 1
    Limited Data Types: JSON supports only strings, numbers, booleans, arrays, objects, and null. It lacks native representations for Dates, 64-bit integers, regular expressions, and raw binary bytes.
  2. 2
    Text Parsing Overhead: Text JSON requires parsing strings character-by-character on every query, which is computationally expensive.
  3. 3
    No Traversal Offsets: Finding a field in a large nested JSON document requires scanning the entire string up to that character.

BSON (Binary JSON) solves these issues:

  • Binary Encoding: Compact binary representation with prefixed length bytes for fast traversal.
  • Rich Type Support: Native ISODate, ObjectId, Decimal128 (high-precision financial arithmetic), Int64, and BinData.
1JSON Representation:
2{"name": "Laptop", "price": 999.99, "created": "2026-09-15T00:00:00Z"}
3 
4BSON Storage:
5\x16\x00\x00\x00\x02name\x00\x07\x00\x00\x00Laptop\x00\x01price\x00\x3d\x0a\xd7\xa3\x70\x3f\x8f\x40...

2. Anatomy of the MongoDB ObjectId

Every MongoDB document requires a unique primary key _id. If not provided, MongoDB automatically generates a 12-byte ObjectId:

1| 4-Byte Timestamp | 5-Byte Random Value | 3-Byte Incrementing Counter |
2| (Seconds epoch) | (Process unique) | (Per-process counter) |
  • Built-in Timestamp: You can extract the exact creation timestamp of any document using doc._id.getTimestamp() without storing an extra createdAt field!
  • Natural Ordering: ObjectIds are roughly ordered chronologically.

3. The WiredTiger Storage Engine

MongoDB's default storage engine, WiredTiger, is responsible for managing data between memory and disk:

  • Document-Level Concurrency: Provides fine-grained document-level locking for write operations, maximizing multi-core CPU throughput.
  • In-Memory LRU Cache: Uses 50% of available server RAM minus 1 GB by default to cache hot indexes and documents.
  • Snappy / Zlib Compression: Transparently compresses collection data and indexes on disk, typically saving 50% to 70% of storage costs compared to raw JSON.
  • Write-Ahead Logging (Journaling): Commits write operations to an on-disk journal before flushing to data files, guaranteeing durability across sudden server power outages.

Interactive Quiz• Knowledge Check

Multiple Choice Questions

Question 1
What is BSON in MongoDB?
Question 2
How many bytes does a standard MongoDB ObjectId occupy in memory?
Question 3
What can be extracted directly from a document's default _id ObjectId without querying any other field?
Question 4
What type of concurrency locking does the WiredTiger storage engine provide for write operations?
Question 5
What role does "Journaling" play in MongoDB?

Next Lesson

MongoDB Atlas Cloud Setup, Network Whitelisting & Compass GUI

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Document Databases vs Relational SQL: CAP Theorem & When to Use NoSQLMongoDB Atlas Cloud Setup, Network Whitelisting & Compass GUI

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master MongoDB & Mongoose with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext