Slide 1

Slide 1 text

Senior Consulting Engineer, MongoDB Inc. James Tan #NoSQLEast Intro to MongoDB

Slide 2

Slide 2 text

What is MongoDB?

Slide 3

Slide 3 text

MongoDB is a ___________ database •  Document •  Open source •  High performance •  Horizontally scalable •  Full featured

Slide 4

Slide 4 text

Document Database •  Not for .PDF & .DOC files •  A document is essentially an associative array •  Document = JSON object •  Document = PHP Array •  Document = Python Dict •  Document = Ruby Hash •  etc.

Slide 5

Slide 5 text

Open Source •  MongoDB is an open source project •  On GitHub •  Licensed under the AGPL •  Started & sponsored by MongoDB Inc (formerly 10gen) •  Commercial licenses available •  Contributions welcome

Slide 6

Slide 6 text

High Performance •  Written in C++ •  Extensive use of memory-mapped files i.e. read-through write-through memory caching •  Runs nearly everywhere •  Data serialized as BSON (fast parsing) •  Full support for primary & secondary indexes •  Document model = less work

Slide 7

Slide 7 text

Horizontally Scalable (scale out) Shard N Shard 3 Shard 2 Shard 1 Horizontally Scalable Auto-Sharding •  Increase capacity as you go •  Commodity and cloud architectures •  Improved operational simplicity and cost visibility

Slide 8

Slide 8 text

“Hot” Dataset Exceeds Physical Memory

Slide 9

Slide 9 text

Read/Write Throughput Exceeds I/O

Slide 10

Slide 10 text

Full Featured Rich Queries •  Find Paul’s cars •  Find everybody in London with a car built between 1970 and 1980 Geospatial •  Find all of the car owners within 5km of Trafalgar Sq. Text Search •  Find all the cars described as having leather seats Aggregation •  Calculate the average value of Paul’s car collection Map Reduce •  What is the ownership pattern of colors by geography over time? (is purple trending up in China?) { ! first_name: ‘Paul’,! surname: ‘Miller’,! city: ‘London’,! location: [45.123,47.232],! cars: [ ! { model: ‘Bentley’,! year: 1973,! value: 100000, … },! { model: ‘Rolls Royce’,! year: 1965,! value: 330000, … }! }! }!

Slide 11

Slide 11 text

Operational Database Landscape

Slide 12

Slide 12 text

Who uses MongoDB?

Slide 13

Slide 13 text

7,000,000+ MongoDB Downloads 200,000+ Online Education Registrants 35,000+ MongoDB Management Service (MMS) Users 30,000+ MongoDB User Group Members 20,000+ MongoDB Days Attendees Global Community

Slide 14

Slide 14 text

Leading Organizations Rely on MongoDB

Slide 15

Slide 15 text

MongoDB Use Cases Big Data Product & Asset Catalogs Security & Fraud Internet of Things Database-as-a- Service Mobile Apps Customer Data Management Single View Social & Collaboration Content Management Intelligence Agencies Top Investment and Retail Banks Top US Retailer Top Global Shipping Company Top Industrial Equipment Manufacturer Top Media Company Top Investment and Retail Banks

Slide 16

Slide 16 text

Data Model

Slide 17

Slide 17 text

Terminology RDBMS MongoDB Table, View ➜ Collection Row ➜ Document Index ➜ Index Join ➜ Embedded Document Foreign Key ➜ Reference Partition ➜ Shard

Slide 18

Slide 18 text

Let’s Build a Blog

Slide 19

Slide 19 text

Typical (relational) ERD User ·Name ·Email address Category ·Name ·URL Comment ·Comment ·Date ·Author Article ·Name ·Slug ·Publish date ·Text Tag ·Name ·URL

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

MongoDB ERD User ·Name ·Email address Article ·Name ·Slug ·Publish date ·Text ·Author Comment[] ·Comment ·Date ·Author Tag[] ·Value Category[] ·Value Linking vs embedding

Slide 22

Slide 22 text

Sample Article document { ! _id: ObjectId(…),! name: ‘My first blog post’,! slug: ‘/2014_01_23_My_first_blog_post’,! published: ISODate(‘2014-01-23T12:23:42‘),! user_id: ObjectId(…),! text: ‘This is the very first blog post…’,! author: ‘John Doe’,! tags: [ ‘NoSQL’, ’MongoDB’ ],! categories: [ ‘Work’ ]! comments: [
 { name: ‘Harry’,
 text: ‘Nice blog post!’,! ts: ISODate(‘2014-02-03T11:41:25‘) },! …! ]! }! Fields Fields can contain an array of sub- documents Fields can contain arrays Typed field values Date

Slide 23

Slide 23 text

Deployment models

Slide 24

Slide 24 text

Secondary Secondary Primary Client Application Driver Write Read Deployment - Standalone Arbiter

Slide 25

Slide 25 text

Secondary Secondary Primary Client Application Driver Write Read Deployment - Replica Set Arbiter

Slide 26

Slide 26 text

Node 1 Secondary Config Server Node 1 Secondary Config Server Node 1 Secondary Config Server Shard Shard Shard Mongos App Server Mongos App Server Mongos App Server Deployment – Sharded cluster

Slide 27

Slide 27 text

Control of reads and writes •  Read preferences: primary (default), primaryPreferred, secondary, secondaryPreferred, nearest! •  Write concerns: (e.g. w=1, w=majority, j=1, wtimeout=) •  Tagged reads and writes (to specific/subset of nodes) •  Tag aware sharding

Slide 28

Slide 28 text

Questions?

Slide 29

Slide 29 text

Senior Consulting Engineer, MongoDB Inc. James Tan #NoSQLEast Thank You