Slide 1

Slide 1 text

Senior Consulting Engineer, MongoDB Inc. James Tan #DevOSSAzureDays 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

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 •  Dynamic schema •  Strongly consistent (default) •  Complex data types and operators (e.g. arrays, sets) •  Rich queries, aggregation, and full-text search •  Geospatial features, GridFS •  Built-in replication and automatic failover (HA & DR) •  Easy scale out (sharding)

Slide 11

Slide 11 text

Database Landscape Depth of Functionality Scalability & Performance Memcached MongoDB RDBMS

Slide 12

Slide 12 text

Schema design

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

Let’s Build a Blog

Slide 15

Slide 15 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 16

Slide 16 text

No content

Slide 17

Slide 17 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 18

Slide 18 text

Deployment models

Slide 19

Slide 19 text

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

Slide 20

Slide 20 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 21

Slide 21 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 22

Slide 22 text

MongoDB on Azure

Slide 23

Slide 23 text

MongoDB on Azure •  Fully managed Service (SaaS) –  MongoLab, Azure Store (preview) –  Easiest option •  Partly managed Platform (PaaS) –  Cloud Service: MongoDB worker roles (C# + Windows only) •  Self managed Infrastructure (IaaS) –  MongoDB Azure installer (Windows only) –  Self configured (Linux or Windows) •  Most flexible, but more work

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Demo: Setting up MongoDB on Windows in Azure

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Install MongoDB Windows service •  Install steps (Windows only): http://docs.mongodb.org/manual/tutorial/install- mongodb-on-windows/#configure-a-windows- service-for-mongodb •  Start / Stop service: –  Command prompt / Power Shell: •  net start mongodb –  Or with Windows Services GUI in Control Panel –  Check MongoDB log file for potential warning and errors

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

MongoDB metrics with mongostat   •  Samples MongoDB metrics every second •  Displays metrics like operation counters (e.g. number of inserts, updates, delete), memory flushes, memory utilization, lock %, queued reads/writes, number of connections, etc.

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Admin GUIs •  There are many (3rd party) options •  Personal recommendations: RoboMongo (cross platform) and MongoVUE (Windows only) •  Full list: http://docs.mongodb.org/ecosystem/tools/ administration-interfaces/

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Monitoring (and more) with MMS

Slide 36

Slide 36 text

What is MMS? •  MMS: MongoDB Management Service •  Available Online and On-Premise •  Monitoring (online version is free) •  Database and system metrics •  Alerts (e.g. SMS, emails, HipChat, PagerDuty) •  Backup •  Automation (alpha) •  https://www.youtube.com/watch?v=nSJiVXNsPHk

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

Find out more…

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

Questions?

Slide 44

Slide 44 text

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