SlideShare a Scribd company logo
@mongodb @mdirolf   http://www.mongodb.org/
How it Works




               http://www.flickr.com/photos/tmh9/677919415/
BSON
       {“hello”: “bson”}



x15 x00 x00 x00 x02 h e
   l l o x00 x05 x00 x00
  x00 b s o n x00 x00


                           http://bsonspec.org
Messages


• TCP/IP Wire Protocol
• Separate messages for
  insert, update, query, get_more, delete, etc.




      http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol
Anatomy of an insert
    use foo;
    db.test.insert({“hello”: “bson”});



message length      request id        response id op code (insert)
x67x00x00x0     xXXxXXxXX     x00x00x00x xd2x07x00x00
       0                xXX               00
    reserved            collection name            document(s)
 x00x00x00x00        f o o . t e s t x00   BSON({“hello”: “bson”})




             http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol
Memory mapped
 storage engine
Commands
          db.foo.drop();

              =
db.foo.runCommand({drop: "foo"});
              =
  db.$cmd.findOne({drop: "foo"});

                =
db.$cmd.find({drop: "foo"}).limit(-1);
Query optimizer
        find({x: 10, y: “foo”})


         scan
                         terminate
   index on x

index on y         remember
Geohashing
               (20, 10)

    (0001 0100, 0000 1010)
        0000 0010 0110 0100
(21, 9) 0000 0010 0110 0011


    Problem: bit-flips (127 vs 128)
Replication
                                            Replica sets
        Master - slave

                                   master                  slave
        master

                                   master                  slave
slave         slave        slave
                                   master              master
    slave
                                    slave              master
Replication


• oplog - capped collection
• idempotent ($inc -> $set)
Auto-sharding
                    Shards

           mongod   mongod    mongod
                                         ...
Config      mongod   mongod    mongod
Servers

mongod

mongod

mongod
                    mongos    mongos   ...


                     client

More Related Content

PDF
Inside MongoDB: the Internals of an Open-Source Database
PDF
The Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScale
PDF
MongodB Internals
PDF
MongoDB .local Toronto 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...
PPTX
MongoDB Schema Design: Four Real-World Examples
PDF
Indexing
PPTX
Data oriented design and c++
PPTX
Introduction to MongoDB
Inside MongoDB: the Internals of an Open-Source Database
The Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScale
MongodB Internals
MongoDB .local Toronto 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...
MongoDB Schema Design: Four Real-World Examples
Indexing
Data oriented design and c++
Introduction to MongoDB

What's hot (20)

PDF
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
PPTX
Mongo DB 성능최적화 전략
PPTX
MongoDB
PPTX
Mongo Nosql CRUD Operations
PPTX
PPTX
The Aggregation Framework
PDF
[Pgday.Seoul 2017] 6. GIN vs GiST 인덱스 이야기 - 박진우
PDF
What is the best full text search engine for Python?
PPTX
Indexing with MongoDB
PDF
HBaseCon 2015: Taming GC Pauses for Large Java Heap in HBase
PPT
Introduction to mongodb
PDF
20180726 AWS KRUG - RDS Aurora에 40억건 데이터 입력하기
PDF
Soma search
PPTX
Introduction to Storm
PDF
HBaseCon 2012 | HBase Schema Design - Ian Varley, Salesforce
PDF
HBase Advanced - Lars George
PDF
Understanding Database Transactions and Hibernate Sessions in Grails
PPTX
Introduction to Redis
PPTX
Introducing MongoDB Atlas
PPTX
Introduction to Aerospike
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
Mongo DB 성능최적화 전략
MongoDB
Mongo Nosql CRUD Operations
The Aggregation Framework
[Pgday.Seoul 2017] 6. GIN vs GiST 인덱스 이야기 - 박진우
What is the best full text search engine for Python?
Indexing with MongoDB
HBaseCon 2015: Taming GC Pauses for Large Java Heap in HBase
Introduction to mongodb
20180726 AWS KRUG - RDS Aurora에 40억건 데이터 입력하기
Soma search
Introduction to Storm
HBaseCon 2012 | HBase Schema Design - Ian Varley, Salesforce
HBase Advanced - Lars George
Understanding Database Transactions and Hibernate Sessions in Grails
Introduction to Redis
Introducing MongoDB Atlas
Introduction to Aerospike
Ad

Viewers also liked (11)

PDF
MongoDB World 2016: Deciphering .explain() Output
PDF
MongoDB Performance Tuning
PDF
Deciphering Explain Output
PDF
MongoDB WiredTiger Internals
PPTX
Performance Tuning and Optimization
PPTX
Availability and scalability in mongo
PPTX
Trading up: Adding Flexibility and Scalability to Bouygues Telecom with MongoDB
PPTX
Agility and Scalability with MongoDB
PPT
MongoDB Basic Concepts
PPTX
Scaling and Transaction Futures
PPTX
Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)
MongoDB World 2016: Deciphering .explain() Output
MongoDB Performance Tuning
Deciphering Explain Output
MongoDB WiredTiger Internals
Performance Tuning and Optimization
Availability and scalability in mongo
Trading up: Adding Flexibility and Scalability to Bouygues Telecom with MongoDB
Agility and Scalability with MongoDB
MongoDB Basic Concepts
Scaling and Transaction Futures
Developing with the Modern App Stack: MEAN and MERN (with Angular2 and ReactJS)
Ad

Similar to MongoDB: How it Works (20)

PDF
FrozenRails Training
PDF
MongoDB: Optimising for Performance, Scale & Analytics
PDF
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
PDF
Unix executable buffer overflow
PDF
Fisl - Deployment
KEY
About memcached
PPT
Writing Metasploit Plugins
PDF
Supercharging Cassandra - GOTO Amsterdam
PDF
我在豆瓣使用Emacs
PDF
Testing stateful, concurrent, and async systems using test.check
PDF
Blogopolisの裏側
PDF
Performance tweaks and tools for Linux (Joe Damato)
PPTX
Inferno Scalable Deep Learning on Spark
PDF
XS 2008 Boston Project Snowflock
PDF
Hadoop - Lessons Learned
PDF
EC2とVarnishで画像配信
PDF
Perl at SkyCon'12
PDF
Perf EMC VNX5100 vs IBM DS5300 Eng
PPTX
Driver Debugging Basics
KEY
You know, for search. Querying 24 Billion Documents in 900ms
FrozenRails Training
MongoDB: Optimising for Performance, Scale & Analytics
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
Unix executable buffer overflow
Fisl - Deployment
About memcached
Writing Metasploit Plugins
Supercharging Cassandra - GOTO Amsterdam
我在豆瓣使用Emacs
Testing stateful, concurrent, and async systems using test.check
Blogopolisの裏側
Performance tweaks and tools for Linux (Joe Damato)
Inferno Scalable Deep Learning on Spark
XS 2008 Boston Project Snowflock
Hadoop - Lessons Learned
EC2とVarnishで画像配信
Perl at SkyCon'12
Perf EMC VNX5100 vs IBM DS5300 Eng
Driver Debugging Basics
You know, for search. Querying 24 Billion Documents in 900ms

More from Mike Dirolf (17)

KEY
Inside PyMongo - MongoNYC
PDF
MongoDB at FrozenRails
KEY
Python Development (MongoSF)
PDF
Introduction to MongoDB
KEY
MongoDB at ZPUGDC
KEY
MongoDB hearts Django? (Django NYC)
KEY
MongoDB at CodeMash 2.0.1.0
PDF
MongoDB at RubyConf
KEY
MongoDB at RuPy
KEY
MongoDB at RubyEnRails 2009
KEY
MongoDB Strange Loop 2009
KEY
MongoDB Hadoop DC
KEY
MongoDB London PHP
KEY
MongoDB EuroPython 2009
KEY
MongoDB NYC Python
KEY
MongoDB SF Python
KEY
MongoDB SF Ruby
Inside PyMongo - MongoNYC
MongoDB at FrozenRails
Python Development (MongoSF)
Introduction to MongoDB
MongoDB at ZPUGDC
MongoDB hearts Django? (Django NYC)
MongoDB at CodeMash 2.0.1.0
MongoDB at RubyConf
MongoDB at RuPy
MongoDB at RubyEnRails 2009
MongoDB Strange Loop 2009
MongoDB Hadoop DC
MongoDB London PHP
MongoDB EuroPython 2009
MongoDB NYC Python
MongoDB SF Python
MongoDB SF Ruby

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
KodekX | Application Modernization Development
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
cuic standard and advanced reporting.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Approach and Philosophy of On baking technology
The AUB Centre for AI in Media Proposal.docx
Spectroscopy.pptx food analysis technology
Reach Out and Touch Someone: Haptics and Empathic Computing
Digital-Transformation-Roadmap-for-Companies.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
sap open course for s4hana steps from ECC to s4
Building Integrated photovoltaic BIPV_UPV.pdf
Spectral efficient network and resource selection model in 5G networks
Dropbox Q2 2025 Financial Results & Investor Presentation
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
KodekX | Application Modernization Development
“AI and Expert System Decision Support & Business Intelligence Systems”
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
cuic standard and advanced reporting.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

MongoDB: How it Works

  • 1. @mongodb @mdirolf http://www.mongodb.org/
  • 2. How it Works http://www.flickr.com/photos/tmh9/677919415/
  • 3. BSON {“hello”: “bson”} x15 x00 x00 x00 x02 h e l l o x00 x05 x00 x00 x00 b s o n x00 x00 http://bsonspec.org
  • 4. Messages • TCP/IP Wire Protocol • Separate messages for insert, update, query, get_more, delete, etc. http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol
  • 5. Anatomy of an insert use foo; db.test.insert({“hello”: “bson”}); message length request id response id op code (insert) x67x00x00x0 xXXxXXxXX x00x00x00x xd2x07x00x00 0 xXX 00 reserved collection name document(s) x00x00x00x00 f o o . t e s t x00 BSON({“hello”: “bson”}) http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol
  • 7. Commands db.foo.drop(); = db.foo.runCommand({drop: "foo"}); = db.$cmd.findOne({drop: "foo"}); = db.$cmd.find({drop: "foo"}).limit(-1);
  • 8. Query optimizer find({x: 10, y: “foo”}) scan terminate index on x index on y remember
  • 9. Geohashing (20, 10) (0001 0100, 0000 1010) 0000 0010 0110 0100 (21, 9) 0000 0010 0110 0011 Problem: bit-flips (127 vs 128)
  • 10. Replication Replica sets Master - slave master slave master master slave slave slave slave master master slave slave master
  • 11. Replication • oplog - capped collection • idempotent ($inc -> $set)
  • 12. Auto-sharding Shards mongod mongod mongod ... Config mongod mongod mongod Servers mongod mongod mongod mongos mongos ... client