WiredTiger & What's New in 3.0

55

Transcript of WiredTiger & What's New in 3.0

Page 1: WiredTiger & What's New in 3.0
Page 2: WiredTiger & What's New in 3.0

WiredTiger & What's New in 3.0

Page 3: WiredTiger & What's New in 3.0

3

I'm Excited

Page 4: WiredTiger & What's New in 3.0

4

AgendaMongoDB 3.0Storage Engine APIWiredTiger Architecture

Page 5: WiredTiger & What's New in 3.0
Page 6: WiredTiger & What's New in 3.0

6

Benefits

Page 7: WiredTiger & What's New in 3.0

7

Performance!

Page 8: WiredTiger & What's New in 3.0

8

Compression in Action

(Flights database, ht Asya)

Page 9: WiredTiger & What's New in 3.0

But 3.0 is more than WiredTiger

Page 10: WiredTiger & What's New in 3.0

http://www.livingincebuforums.com/ipb/uploads/monthly_10_2011/post-198-0-67871200-1318223706.jpg

Pluggable Storage Engine API

Page 11: WiredTiger & What's New in 3.0

11

MongoDB Architecture

Content Repo

IoT Sensor Backend Ad Service Customer

Analytics Archive

MongoDB Query Language (MQL) + Native Drivers

MongoDB Document Data Model

MMAP V1 WT In-Memory ? ?

Supported in MongoDB 3.0 Future Possible Storage Engines

Man

agem

ent

Sec

urity

Example Future State

Experimental

Page 12: WiredTiger & What's New in 3.0

12

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 …)

Page 13: WiredTiger & What's New in 3.0

Storage Engines

Page 14: WiredTiger & What's New in 3.0

2 Storage Engines Available

… and more in the making!MMAPv1 WiredTiger

Page 15: WiredTiger & What's New in 3.0

15

MongoDB Architecture

Content Repo

IoT Sensor Backend Ad Service Customer

Analytics Archive

MongoDB Query Language (MQL) + Native Drivers

MongoDB Document Data Model

MMAP V1 WT In-Memory ? ?

Supported in MongoDB 3.0 Future Possible Storage Engines

Man

agem

ent

Sec

urity

Example Future State

Experimental

Page 16: WiredTiger & What's New in 3.0

mongod --storageEngine wiredTiger

Page 17: WiredTiger & What's New in 3.0

MMAPv1

https://angrytechnician.files.wordpress.com/2009/05/memory.jpg

Page 18: WiredTiger & What's New in 3.0

18

MMAPv1

Page 19: WiredTiger & What's New in 3.0

19

MMAPv1

• Improved concurrency control

• Great performance on read-heavy workloads

• Data & Indexes memory mapped into virtual address space

• Data access is paged into RAM

• OS evicts using LRU

• More frequently used pages stay in RAM

3.0 Default

Page 20: WiredTiger & What's New in 3.0

http://cdn.theatlantic.com/static/infocus/ngt051713/n10_00203194.jpg

WiredTiger

Page 21: WiredTiger & What's New in 3.0

21

What is WiredTiger?• Storage engine company founded by BerkeleyDB alums• Recently acquired by MongoDB• Available as a storage engine option in MongoDB 3.0

Page 22: WiredTiger & What's New in 3.0

22

Motivation for WiredTiger• Take advantage of modern hardware:

– many CPU cores– lots of RAM

• Minimize contention between threads– lock-free algorithms, e.g., hazard pointers– eliminate blocking due to concurrency control

• Hotter cache and more work per I/O– compact file formats– compression

Page 23: WiredTiger & What's New in 3.0

WiredTiger Architecture

Page 24: WiredTiger & What's New in 3.0

24

WiredTiger Architecture

All operations will be handled atomically through the transaction mechanism

For data access methods MongoDB is

using the Row storage, although we are working on more options for future

versions

Page 25: WiredTiger & What's New in 3.0

In-memory Performance

Page 26: WiredTiger & What's New in 3.0

26

Traditional B+tree (ht wikipedia)

Page 27: WiredTiger & What's New in 3.0

27

Trees in cache

Page 28: WiredTiger & What's New in 3.0

28

Hazard Pointers

1 memory flush

Page 29: WiredTiger & What's New in 3.0

29

Pages in cache

Page 30: WiredTiger & What's New in 3.0

30

In-memory performance• Trees in cache are optimized for in-memory access• Follow pointers to traverse a tree

– no locking to access pages in cache• Keep updates separate from clean data• Do structural changes (eviction, splits) in background threads

Page 31: WiredTiger & What's New in 3.0

Document-level Concurrency

Page 32: WiredTiger & What's New in 3.0

32

What is Concurrency Control?

• Computers have– multiple CPU cores– multiple I/O paths

• To make the most of the hardware, software has to execute multiple operations in parallel

• Concurrency control has to keep data consistent• Common approaches:

– locking– keeping multiple versions of data (MVCC)

Page 33: WiredTiger & What's New in 3.0

33

WiredTiger Concurrency Control

Page 34: WiredTiger & What's New in 3.0

34

Pages in cacheskiplist

Page 35: WiredTiger & What's New in 3.0

35

Multiversion Concurrency Control (MVCC)

• Multiple versions of records kept in cache• Readers see the committed version before the transaction started

– MongoDB “yields” turn large operations into small transactions• Writers can create new versions concurrent with readers• Concurrent updates to a single record cause write conflicts

– MongoDB retries with back-off

Page 36: WiredTiger & What's New in 3.0

36

MVCC In Action

updateupdate

Page 37: WiredTiger & What's New in 3.0

Compression

Page 38: WiredTiger & What's New in 3.0

38

WiredTiger Page I/O

Page 39: WiredTiger & What's New in 3.0

39

Trees in cache

read required

Page 40: WiredTiger & What's New in 3.0

40

Pages in cache

reconciled during write

Page 41: WiredTiger & What's New in 3.0

41

Checksums• A checksum is stored with every page• Checksums are validated during page read

– detects filesystem corruption, random bitflips• WiredTiger stores the checksum with the page address (typically

in a parent page)– extra safety against reading a stale page image

Page 42: WiredTiger & What's New in 3.0

42

Compression• WiredTiger uses snappy compression by default in MongoDB• Supported compression algorithms:

– snappy [default]: good compression, low overhead– zlib: better compression, more CPU– none

• Indexes also use prefix compression– stays compressed in memory

Page 43: WiredTiger & What's New in 3.0

43

Compression in Action

(Flights database, ht Asya)

Page 44: WiredTiger & What's New in 3.0

What's Next

Page 45: WiredTiger & What's New in 3.0

45

Page 46: WiredTiger & What's New in 3.0

46

WiredTiger LSM support

• Out-of-order insert workloads• Data set much larger than cache• Query performance is not (as) important• Resource overhead of background maintenance

acceptable

Page 47: WiredTiger & What's New in 3.0

47

Page 48: WiredTiger & What's New in 3.0

48

What’s next for WiredTiger?

• Tune for (many) more workloads– avoid stalls during checkpoints with 100GB+ caches– make capped collections (including oplog) more efficient– Mark Callaghan seeing ~2x speedup in 3.1 snapshots:

http://smalldatum.blogspot.com/ • Make Log Structured Merge (LSM) trees work well with MongoDB

– out-of-cache, write-heavy workloads• Adding encryption• More advanced transactional semantics in the storage engine API

Page 49: WiredTiger & What's New in 3.0

49

Updates and Upgrades

• 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 – Relaunch w/ --storageEngine=wiredTiger– Rollover

Page 50: WiredTiger & What's New in 3.0

50

Gotchas

• No 32-bit Support– WT is 64bit only

• system.indexes & system.namespaces deprecated– Explicit commands: db.getIndexes() db.getCollectionNames()

Page 51: WiredTiger & What's New in 3.0

https://tingbudongchine.files.wordpress.com/2012/08/lemonde1.jpeg

Take Aways

Page 52: WiredTiger & What's New in 3.0

52

MongoDB 3.0

• Pluggable Storage Engine API• Storage Engines• Large Replica Sets• Big Polygon• Security Enhancements – SCRAM • Audit Trail• Simplified Operations – Ops Manager• Tools Rewrite

Page 53: WiredTiger & What's New in 3.0

53

Benefits

Page 54: WiredTiger & What's New in 3.0

54

Performance!

http://www.mongodb.com/lp/white-paper/benchmark-report

Page 55: WiredTiger & What's New in 3.0

http://cl.jroo.me/z3/v/D/C/e/a.baa-Too-many-bicycles-on-the-van.jpg

Norberto LeiteTechnical [email protected]@nleite

Obrigado!