SlideShare a Scribd company logo
MongoDB v3.0 Deep Dive
{ Name: ‘Bryan Reinero’,
Title: ‘Developer Advocate’,
Twitter: ‘@blimpyacht’,
Email: ‘bryan@mongdb.com’ }
2
Agenda
• Storage Engine API
• MmapV1
• WiredTiger
• Document Level Concurrency
• Index Improvements
• The Future
3
Storage Engine API
• Allows to "plug-in" different storage engines
– Different work sets require different performance characteristics
– mmapv1 is not ideal for all workloads
– More flexibility
• Can mix storage engines on same replica set/sharded cluster
• Opportunity to integrate further ( HDFS, native encrypted, hardware
optimized …)
4
Storage Engine API
StorageEngine
Top Level Class for creating a Storage Engine
RecoveryUnit
Durability interface. Ensures data is persisted. On-disk information mutated through this interface
DatabaseCatalogEntry
MongoDB Logical Database
CollectionCatalogEntry
MongoDB Collection
SortedDataInterface
Index implementation. Not all Indexes are B-trees
5
MongoDB Storage Engines
• <= MongoDB 2.6
– One unique mechanism using Memory Mapped Files
– "mmapv1" Storage Engine
• MongoDB 3.0 has a few more options
– mmapv1 – default
– wiredTiger
– (in_memory – experimental only)
MMAPv1
https://angrytechnician.files.wordpress.com/2009/05/memory.jpg
7
MMAPv1
Mongo db v3_deep_dive
9
What is WiredTiger?
• Storage engine company founded by BerkeleyDB alums
• Recently acquired by MongoDB
• Available as a storage engine option in MongoDB 3.0
10
Why is WiredTiger Awesome
• Document-level concurrency
• Disk Compression
• Consistency without journaling
• Better performance on many workloads
– write heavy
11
Improving Concurrency
• 2.2 – Global Lock
• 2.4 – Database-level Locking
• 3.0 MMAPv1 – Collection-level Locking
• 3.0 WT – Document-level
– Writes no longer block all other writes
– Higher level of concurrency leads to more CPU usage
12
Lock Free Algorithms
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 6
9 2
10 1
11 1
12 5
13 4
15 5
14 5
http://ses.library.usyd.edu.au/bitstream/2123/5353/1/michael-cahill-2009-thesis.pdf
13
Lock Free Algorithms
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 6
9 2
10 1
11 1
12 5
13 4
15 5
14 5
Read0(8) = 6
14
Lock Free Algorithms
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 6
9 2
10 1
11 1
12 5
13 4
15 5
14 5
Read0(8) = 6
Read1(8) = 6
Read2(8) = 6
15
Lock Free Algorithms
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 6
9 2
10 1
11 1
12 5
13 4
15 5
14 5
write3(8, $inc )
write4(8, $inc )
16
Lock Free Algorithms
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 6
9 2
10 1
11 1
12 5
13 4
15 5
14 5
write3(8, $inc )
write4(8, $inc )
8 6
8 6
17
Lock Free Algorithms
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 6
9 2
10 1
11 1
12 5
13 4
15 5
14 5
write3(8, $inc )
write4(8, $inc )
8 6
8 7
18
Lock Free Algorithms
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 7
9 2
10 1
11 1
12 5
13 4
15 5
14 5
write3(8, $inc )
write4(8, $inc )
8 6
8 7
Compare
&
Swap
19
Lock Free Algorithms
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 7
9 2
10 1
11 1
12 5
13 4
15 5
14 5
write3(8, $inc )
8 6
20
Lock Free Algorithms
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 7
9 2
10 1
11 1
12 5
13 4
15 5
14 5
write3(8, $inc )
8 7
21
Lock Free Algorithms
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 7
9 2
10 1
11 1
12 5
13 4
15 5
14 5
write3(8, $inc )
8 7Compare
&
!swap
22
Lock Free Algorithms
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 7
9 2
10 1
11 1
12 5
13 4
15 5
14 5
write3(8, $inc )
8 7
Re-read & Retry
23
Lock Free Algorithms
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 7
9 2
10 1
11 1
12 5
13 4
15 5
14 5
write3(8, $inc )
8 8
24
Document Level Concurrency Control
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 8
9 2
10 1
11 1
12 5
13 4
15 5
14 5
Compare
&
Swap
write3(8, $inc )
8 8
25
Document Level Concurrency Control
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 8
9 2
10 1
11 1
12 5
13 4
15 5
14 5
Compare
&
Swap
write3(8, $inc )
8 8
26
Read More
http://ses.library.usyd.edu.au/bitstream/2123/5353/1/michael-cahill-2009-thesis.pdf
27
Wired Tiger Concurrency
• Fine grained
• Lock free
• Wait free
• Stone cold
• Superfly
28
Compression
• Data is compressed on disk
• 2 supported algorithms
– snappy: default. Good compression,
relatively low overhead
– zlib: Better
• Indexes are compressed using
prefix compression
– Allows compression in memory
29
Tuning Wired Tiger
File System CacheWired Tiger Cache
Total RAM
Non-
mapped
30
Tuning Wired Tiger
File System CacheWired Tiger Cache
Total RAM
Default 50% RAM
Non-
mapped
31
Tuning Wired Tiger
File System CacheWired Tiger Cache
Total RAM
Default 50% RAM
Non-
mapped
Knobs
• Wired Tiger Cache Size
• Compression
• Snappy
• Zlib
• off
32
Indexing Improvements
MMapV11 4
2 2
3 5
4 7
5 4
6 9
7 3
8 6
9 2
10 1
11 1
12 5
13 4
15 5
14 5
33
Indexing Improvements
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 6
9 2
10 1
11 1
12 5
13 4
15 5
14 5
{
_id: 6,
categories: [
“database”,
“distributed”,
“document store”
]
}
34
Indexing Improvements
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 6
9 2
10 1
11 1
12 5
13 4
15 5
14 5
{$push:
{
categories:
“sharded”
}
}
{
_id: 6,
categories: [
“database”,
“distributed”,
“document store”,
“sharded”
]
}
35
Indexing Improvements
1 4
2 2
3 5
4 7
5 4
6 9
7 3
8 6
9 2
10 1
11 1
12 5
13 4
15 5
14 5
{
_id: 6,
categories: [
“database”,
“distributed”,
“document store”,
“sharded”
]
}
36
Indexing Improvements
1 4
2 2
3 5
4 7
5 4
7 3
8 6
9 2
10 1
11 1
12 5
13 4
15 5
14 5
6 9
MMapV1
6 9
37
Indexing Improvements
1 4
2 2
3 5
4 7
5 4
7 3
8 6
9 2
10 1
11 1
12 5
13 4
15 5
14 5
6 9
MMapV1
38
Indexing Improvements
1 4
2 2
3 5
4 7
5 4
7 3
8 6
9 2
10 1
11 1
12 5
13 4
15 5
14 5
6 9
WiredTiger
The RecordId != DiskLoc
39
Consistency without Journaling
• MMAPv1 uses write-ahead log (journal) to guarantee consistency
• WT doesn't have this need: no in-place updates
– Write-ahead log committed at checkpoints
• 2GB or 60sec by default – configurable!
– No journal commit interval: writes are written to journal as they come in
– Better for insert-heavy workloads
• Replication guarantees the durability
40
7x-10x Performance, 50%-80% Less Storage
How: WiredTiger Storage Engine
• Same data model, same query language,
same ops
• Write performance gains driven by
document-level concurrency control
• Storage savings driven by native
compression
• 100% backwards compatible
• Non-disruptive upgrade
MongoDB 3.0MongoDB 2.6
Performance
https://www.mongodb.com/blog/post/high-performance-
benchmarking-mongodb-and-nosql-systems
41
Playing nice together
• Can not
– Can't copy database files
– Can't just restart w/ same dbpath
• Yes we can!
– Initial sync from replica set works perfectly!
– mongodump/restore
• Rolling upgrade of replica set to WT:
– Shutdown secondary
– Delete dbpath
– Relaunch w/ --storageEngine=wiredTiger
– Rollover
AND BEYOND THE INFINITE
VERSION 3.2
43
Storage Engine
Storage Engines
• WiredTiger (now default)
• In-Memory
• Encryption at Rest
Tools
• Schema visualizer
Features
• $lookup (Enterprise)
• Read Committed
• Schema Validation Rules
• Partial Indexes
44
Storage Engine
Storage Engines
• WiredTiger (now default)
• In-Memory
• Encryption at Rest
Tools
• Schema visualizer
Features
• $lookup (Enterprise)
• Read Committed
• Schema Validation Rules
• Partial Indexes
Features now available in
v3.1.6 Community release
Thanks!
{ name: ‘Bryan Reinero’,
title: ‘Developer Advocate’,
twitter: ‘@blimpyacht’,
code: ‘github.com/breinero’
email: ‘bryan@mongdb.com’ }

More Related Content

What's hot (20)

PPTX
SQL Server In-Memory OLTP: What Every SQL Professional Should Know
Bob Ward
 
PDF
Seattle Cassandra Meetup - HasOffers
btoddb
 
PDF
Cassandra Community Webinar: Apache Cassandra Internals
DataStax
 
PDF
Breaking the Sound Barrier with Persistent Memory
HBaseCon
 
PDF
Cassandra Day Atlanta 2015: Diagnosing Problems in Production
DataStax Academy
 
PDF
Troubleshooting redis
DaeMyung Kang
 
PDF
Treasure Data and AWS - Developers.io 2015
N Masahiro
 
PDF
Presto in Treasure Data (presented at db tech showcase Sapporo 2015)
Mitsunori Komatsu
 
PDF
Apache Kafka: New Features That You Might Not Know About
Yaroslav Tkachenko
 
PDF
Introduction to Mongodb execution plan and optimizer
Mydbops
 
PDF
Hoodie: How (And Why) We built an analytical datastore on Spark
Vinoth Chandar
 
PDF
re:dash is awesome
Hiroshi Toyama
 
PDF
Building a Complex, Real-Time Data Management Application
Jonathan Katz
 
PDF
Low latency stream processing with jet
StreamNative
 
PDF
Scaling with sync_replication using Galera and EC2
Marco Tusa
 
PDF
Using apache spark for processing trillions of records each day at Datadog
Vadim Semenov
 
PPTX
Cloud dwh
Alexander Tokarev
 
PPTX
Relational databases for BigData
Alexander Tokarev
 
PPTX
Open Policy Agent for governance as a code
Alexander Tokarev
 
PDF
KSQL: Streaming SQL for Kafka
confluent
 
SQL Server In-Memory OLTP: What Every SQL Professional Should Know
Bob Ward
 
Seattle Cassandra Meetup - HasOffers
btoddb
 
Cassandra Community Webinar: Apache Cassandra Internals
DataStax
 
Breaking the Sound Barrier with Persistent Memory
HBaseCon
 
Cassandra Day Atlanta 2015: Diagnosing Problems in Production
DataStax Academy
 
Troubleshooting redis
DaeMyung Kang
 
Treasure Data and AWS - Developers.io 2015
N Masahiro
 
Presto in Treasure Data (presented at db tech showcase Sapporo 2015)
Mitsunori Komatsu
 
Apache Kafka: New Features That You Might Not Know About
Yaroslav Tkachenko
 
Introduction to Mongodb execution plan and optimizer
Mydbops
 
Hoodie: How (And Why) We built an analytical datastore on Spark
Vinoth Chandar
 
re:dash is awesome
Hiroshi Toyama
 
Building a Complex, Real-Time Data Management Application
Jonathan Katz
 
Low latency stream processing with jet
StreamNative
 
Scaling with sync_replication using Galera and EC2
Marco Tusa
 
Using apache spark for processing trillions of records each day at Datadog
Vadim Semenov
 
Relational databases for BigData
Alexander Tokarev
 
Open Policy Agent for governance as a code
Alexander Tokarev
 
KSQL: Streaming SQL for Kafka
confluent
 

Viewers also liked (6)

PDF
Performance Enhancements In Postgre Sql 8.4
HighLoad2009
 
PPTX
Why PG deserves noSQL fans' respect
divarvel
 
PDF
Advanced Replication Internals
MongoDB
 
PDF
Mongo db3.0 wired_tiger_storage_engine
Kenny Gorman
 
PDF
Postgre sql intro 0
March Liu
 
PDF
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
Severalnines
 
Performance Enhancements In Postgre Sql 8.4
HighLoad2009
 
Why PG deserves noSQL fans' respect
divarvel
 
Advanced Replication Internals
MongoDB
 
Mongo db3.0 wired_tiger_storage_engine
Kenny Gorman
 
Postgre sql intro 0
March Liu
 
Webinar slides: Become a MongoDB DBA - What to Monitor (if you’re really a My...
Severalnines
 
Ad

Similar to Mongo db v3_deep_dive (20)

PPTX
WiredTiger & What's New in 3.0
MongoDB
 
PDF
A Technical Introduction to WiredTiger
MongoDB
 
PDF
https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...
MongoDB
 
PPTX
MongoDB World 2015 - A Technical Introduction to WiredTiger
WiredTiger
 
PPTX
Let the Tiger Roar! - MongoDB 3.0 + WiredTiger
Jon Rangel
 
PPTX
Let the Tiger Roar!
MongoDB
 
PDF
MongoDB Evenings Boston - An Update on MongoDB's WiredTiger Storage Engine
MongoDB
 
PDF
MongoDB WiredTiger Internals
Norberto Leite
 
PPTX
Beyond the Basics 1: Storage Engines
MongoDB
 
PPTX
What'sNnew in 3.0 Webinar
MongoDB
 
PDF
Let the Tiger Roar - MongoDB 3.0
Norberto Leite
 
PDF
MongoDB 3.0 and WiredTiger (Event: An Evening with MongoDB Dallas 3/10/15)
MongoDB
 
PPTX
A Technical Introduction to WiredTiger
MongoDB
 
PDF
MongoDB Miami Meetup 1/26/15: Introduction to WiredTiger
Valeri Karpov
 
PDF
Introduction to new high performance storage engines in mongodb 3.0
Henrik Ingo
 
PPTX
Understanding and tuning WiredTiger, the new high performance database engine...
Ontico
 
PPTX
Conceptos Avanzados 1: Motores de Almacenamiento
MongoDB
 
PDF
WiredTiger In-Memory vs WiredTiger B-Tree
Sveta Smirnova
 
PPTX
Beyond the Basics 1: Storage Engines
MongoDB
 
PDF
MongoDB World 2018: Transactions and Durability: Putting the “D” in ACID
MongoDB
 
WiredTiger & What's New in 3.0
MongoDB
 
A Technical Introduction to WiredTiger
MongoDB
 
https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...
MongoDB
 
MongoDB World 2015 - A Technical Introduction to WiredTiger
WiredTiger
 
Let the Tiger Roar! - MongoDB 3.0 + WiredTiger
Jon Rangel
 
Let the Tiger Roar!
MongoDB
 
MongoDB Evenings Boston - An Update on MongoDB's WiredTiger Storage Engine
MongoDB
 
MongoDB WiredTiger Internals
Norberto Leite
 
Beyond the Basics 1: Storage Engines
MongoDB
 
What'sNnew in 3.0 Webinar
MongoDB
 
Let the Tiger Roar - MongoDB 3.0
Norberto Leite
 
MongoDB 3.0 and WiredTiger (Event: An Evening with MongoDB Dallas 3/10/15)
MongoDB
 
A Technical Introduction to WiredTiger
MongoDB
 
MongoDB Miami Meetup 1/26/15: Introduction to WiredTiger
Valeri Karpov
 
Introduction to new high performance storage engines in mongodb 3.0
Henrik Ingo
 
Understanding and tuning WiredTiger, the new high performance database engine...
Ontico
 
Conceptos Avanzados 1: Motores de Almacenamiento
MongoDB
 
WiredTiger In-Memory vs WiredTiger B-Tree
Sveta Smirnova
 
Beyond the Basics 1: Storage Engines
MongoDB
 
MongoDB World 2018: Transactions and Durability: Putting the “D” in ACID
MongoDB
 
Ad

More from Bryan Reinero (9)

PDF
Event Sourcing + CQRS
Bryan Reinero
 
PDF
MongoDB + Spark
Bryan Reinero
 
PDF
MongoDB, Event Sourcing & Spark
Bryan Reinero
 
PPTX
Mongo db &amp;_spark
Bryan Reinero
 
PPTX
Event sourcing
Bryan Reinero
 
PPTX
Systems of engagement
Bryan Reinero
 
PPTX
Internet of things
Bryan Reinero
 
PPTX
Polyglot Persistence
Bryan Reinero
 
PPTX
Code instrumentation
Bryan Reinero
 
Event Sourcing + CQRS
Bryan Reinero
 
MongoDB + Spark
Bryan Reinero
 
MongoDB, Event Sourcing & Spark
Bryan Reinero
 
Mongo db &amp;_spark
Bryan Reinero
 
Event sourcing
Bryan Reinero
 
Systems of engagement
Bryan Reinero
 
Internet of things
Bryan Reinero
 
Polyglot Persistence
Bryan Reinero
 
Code instrumentation
Bryan Reinero
 

Recently uploaded (20)

PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 

Mongo db v3_deep_dive

  • 1. MongoDB v3.0 Deep Dive { Name: ‘Bryan Reinero’, Title: ‘Developer Advocate’, Twitter: ‘@blimpyacht’, Email: ‘[email protected]’ }
  • 2. 2 Agenda • Storage Engine API • MmapV1 • WiredTiger • Document Level Concurrency • Index Improvements • The Future
  • 3. 3 Storage Engine API • Allows to "plug-in" different storage engines – Different work sets require different performance characteristics – mmapv1 is not ideal for all workloads – More flexibility • Can mix storage engines on same replica set/sharded cluster • Opportunity to integrate further ( HDFS, native encrypted, hardware optimized …)
  • 4. 4 Storage Engine API StorageEngine Top Level Class for creating a Storage Engine RecoveryUnit Durability interface. Ensures data is persisted. On-disk information mutated through this interface DatabaseCatalogEntry MongoDB Logical Database CollectionCatalogEntry MongoDB Collection SortedDataInterface Index implementation. Not all Indexes are B-trees
  • 5. 5 MongoDB Storage Engines • <= MongoDB 2.6 – One unique mechanism using Memory Mapped Files – "mmapv1" Storage Engine • MongoDB 3.0 has a few more options – mmapv1 – default – wiredTiger – (in_memory – experimental only)
  • 9. 9 What is WiredTiger? • Storage engine company founded by BerkeleyDB alums • Recently acquired by MongoDB • Available as a storage engine option in MongoDB 3.0
  • 10. 10 Why is WiredTiger Awesome • Document-level concurrency • Disk Compression • Consistency without journaling • Better performance on many workloads – write heavy
  • 11. 11 Improving Concurrency • 2.2 – Global Lock • 2.4 – Database-level Locking • 3.0 MMAPv1 – Collection-level Locking • 3.0 WT – Document-level – Writes no longer block all other writes – Higher level of concurrency leads to more CPU usage
  • 12. 12 Lock Free Algorithms 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 6 9 2 10 1 11 1 12 5 13 4 15 5 14 5 http://ses.library.usyd.edu.au/bitstream/2123/5353/1/michael-cahill-2009-thesis.pdf
  • 13. 13 Lock Free Algorithms 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 6 9 2 10 1 11 1 12 5 13 4 15 5 14 5 Read0(8) = 6
  • 14. 14 Lock Free Algorithms 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 6 9 2 10 1 11 1 12 5 13 4 15 5 14 5 Read0(8) = 6 Read1(8) = 6 Read2(8) = 6
  • 15. 15 Lock Free Algorithms 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 6 9 2 10 1 11 1 12 5 13 4 15 5 14 5 write3(8, $inc ) write4(8, $inc )
  • 16. 16 Lock Free Algorithms 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 6 9 2 10 1 11 1 12 5 13 4 15 5 14 5 write3(8, $inc ) write4(8, $inc ) 8 6 8 6
  • 17. 17 Lock Free Algorithms 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 6 9 2 10 1 11 1 12 5 13 4 15 5 14 5 write3(8, $inc ) write4(8, $inc ) 8 6 8 7
  • 18. 18 Lock Free Algorithms 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 7 9 2 10 1 11 1 12 5 13 4 15 5 14 5 write3(8, $inc ) write4(8, $inc ) 8 6 8 7 Compare & Swap
  • 19. 19 Lock Free Algorithms 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 7 9 2 10 1 11 1 12 5 13 4 15 5 14 5 write3(8, $inc ) 8 6
  • 20. 20 Lock Free Algorithms 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 7 9 2 10 1 11 1 12 5 13 4 15 5 14 5 write3(8, $inc ) 8 7
  • 21. 21 Lock Free Algorithms 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 7 9 2 10 1 11 1 12 5 13 4 15 5 14 5 write3(8, $inc ) 8 7Compare & !swap
  • 22. 22 Lock Free Algorithms 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 7 9 2 10 1 11 1 12 5 13 4 15 5 14 5 write3(8, $inc ) 8 7 Re-read & Retry
  • 23. 23 Lock Free Algorithms 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 7 9 2 10 1 11 1 12 5 13 4 15 5 14 5 write3(8, $inc ) 8 8
  • 24. 24 Document Level Concurrency Control 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 8 9 2 10 1 11 1 12 5 13 4 15 5 14 5 Compare & Swap write3(8, $inc ) 8 8
  • 25. 25 Document Level Concurrency Control 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 8 9 2 10 1 11 1 12 5 13 4 15 5 14 5 Compare & Swap write3(8, $inc ) 8 8
  • 27. 27 Wired Tiger Concurrency • Fine grained • Lock free • Wait free • Stone cold • Superfly
  • 28. 28 Compression • Data is compressed on disk • 2 supported algorithms – snappy: default. Good compression, relatively low overhead – zlib: Better • Indexes are compressed using prefix compression – Allows compression in memory
  • 29. 29 Tuning Wired Tiger File System CacheWired Tiger Cache Total RAM Non- mapped
  • 30. 30 Tuning Wired Tiger File System CacheWired Tiger Cache Total RAM Default 50% RAM Non- mapped
  • 31. 31 Tuning Wired Tiger File System CacheWired Tiger Cache Total RAM Default 50% RAM Non- mapped Knobs • Wired Tiger Cache Size • Compression • Snappy • Zlib • off
  • 32. 32 Indexing Improvements MMapV11 4 2 2 3 5 4 7 5 4 6 9 7 3 8 6 9 2 10 1 11 1 12 5 13 4 15 5 14 5
  • 33. 33 Indexing Improvements 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 6 9 2 10 1 11 1 12 5 13 4 15 5 14 5 { _id: 6, categories: [ “database”, “distributed”, “document store” ] }
  • 34. 34 Indexing Improvements 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 6 9 2 10 1 11 1 12 5 13 4 15 5 14 5 {$push: { categories: “sharded” } } { _id: 6, categories: [ “database”, “distributed”, “document store”, “sharded” ] }
  • 35. 35 Indexing Improvements 1 4 2 2 3 5 4 7 5 4 6 9 7 3 8 6 9 2 10 1 11 1 12 5 13 4 15 5 14 5 { _id: 6, categories: [ “database”, “distributed”, “document store”, “sharded” ] }
  • 36. 36 Indexing Improvements 1 4 2 2 3 5 4 7 5 4 7 3 8 6 9 2 10 1 11 1 12 5 13 4 15 5 14 5 6 9 MMapV1 6 9
  • 37. 37 Indexing Improvements 1 4 2 2 3 5 4 7 5 4 7 3 8 6 9 2 10 1 11 1 12 5 13 4 15 5 14 5 6 9 MMapV1
  • 38. 38 Indexing Improvements 1 4 2 2 3 5 4 7 5 4 7 3 8 6 9 2 10 1 11 1 12 5 13 4 15 5 14 5 6 9 WiredTiger The RecordId != DiskLoc
  • 39. 39 Consistency without Journaling • MMAPv1 uses write-ahead log (journal) to guarantee consistency • WT doesn't have this need: no in-place updates – Write-ahead log committed at checkpoints • 2GB or 60sec by default – configurable! – No journal commit interval: writes are written to journal as they come in – Better for insert-heavy workloads • Replication guarantees the durability
  • 40. 40 7x-10x Performance, 50%-80% Less Storage How: WiredTiger Storage Engine • Same data model, same query language, same ops • Write performance gains driven by document-level concurrency control • Storage savings driven by native compression • 100% backwards compatible • Non-disruptive upgrade MongoDB 3.0MongoDB 2.6 Performance https://www.mongodb.com/blog/post/high-performance- benchmarking-mongodb-and-nosql-systems
  • 41. 41 Playing nice together • Can not – Can't copy database files – Can't just restart w/ same dbpath • Yes we can! – Initial sync from replica set works perfectly! – mongodump/restore • Rolling upgrade of replica set to WT: – Shutdown secondary – Delete dbpath – Relaunch w/ --storageEngine=wiredTiger – Rollover
  • 42. AND BEYOND THE INFINITE VERSION 3.2
  • 43. 43 Storage Engine Storage Engines • WiredTiger (now default) • In-Memory • Encryption at Rest Tools • Schema visualizer Features • $lookup (Enterprise) • Read Committed • Schema Validation Rules • Partial Indexes
  • 44. 44 Storage Engine Storage Engines • WiredTiger (now default) • In-Memory • Encryption at Rest Tools • Schema visualizer Features • $lookup (Enterprise) • Read Committed • Schema Validation Rules • Partial Indexes Features now available in v3.1.6 Community release
  • 45. Thanks! { name: ‘Bryan Reinero’, title: ‘Developer Advocate’, twitter: ‘@blimpyacht’, code: ‘github.com/breinero’ email: ‘[email protected]’ }

Editor's Notes

  • #5: https://github.com/mongodb/mongo/blob/master/src/mongo/db/storage/storage_engine.h https://github.com/mongodb/mongo/blob/master/src/mongo/db/storage/recovery_unit.h https://github.com/mongodb/mongo/blob/master/src/mongo/db/storage/sorted_data_interface.h https://github.com/mongodb/mongo/blob/master/src/mongo/db/catalog/index_catalog.h Mathias Stearn’s https://www.mongodb.com/presentations/write-yourself-storage-engine-40-minutes
  • #45: Read Commited