MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

90
1 Jared Rosoff @forjared Open source, high performance database NoSQL Now! 2012

description

by Jared Rosoff

Transcript of MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

Page 1: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

1

Jared Rosoff@forjared

Open source, high performance database

NoSQL Now! 2012

Page 2: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

2

Challenges• Variably typed data• Complex objects• High transaction rates• Large data size• High availability

Opportunities• Agility• Cost reduction• Simplification

Overview

Page 3: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

3

Changes Impacting the traditional RDBMS

VOLUME AND TYPE OF DATA

AGILE DEVELOPMENT

• Systems scaling horizontally, not vertically

• Commodity servers• Cloud Computing

• Trillions of records• 10’s of millions of queries

per second• Volume of data• Semi-structured and

unstructured data

• Iterative and continuous• New and emerging apps

NEW ARCHITECTURES

Page 4: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

4

Changes are significantly increasing the cost of delivering applications

DEVELOPER PRODUCTIVITY DECREASES• Needed to add new software layers of ORM, Caching,

Sharding and Message Queue

• Polymorphic, semi-structured and unstructured data not well supported

COST OF DATABASE INCREASES• Increased database licensing cost• Vertical, not horizontal, scaling• High cost of SAN

LAUNCH+30 DAYS

+90 DAYS

+6 MONTHS

+1 YEAR

PROJECT START DENORMALIZE

DATA MODEL STOP USING JOINS CUSTOM

CACHING LAYERCUSTOM

SHARDING

Page 5: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

5

How we got here

Page 6: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

6

• Variably typed data• Complex data objects• High transaction rates• Large data size• High availability • Agile development

Challenges of enterprise data modeling

Page 7: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

7

Variably typed data

• Metadata management• EAV anti-pattern• Sparse table anti-

pattern

Page 8: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

8

Entity Attribute Value

Entity Attribute Value1 Type Book1 Title Inside Intel1 Author Andy Grove2 Type Laptop2 Manufactur

erDell

2 Model Inspiron2 RAM 8gb3 Type Cereal

Difficult to query

Difficult to index

Expensive to query

Page 9: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

9

Sparse Table

Type Title Author Manufacturer Model RAM Screen Width

Book Inside Intel Andy Grove

Laptop Dell Inspiron 8gb 12”

TV Panasonic Viera 52”

MP3 Margin Walker Fugazi Dischord

Constant schema changes

Space inefficient

Overloaded fields

Page 10: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

10

Concrete Table Inheritance

Type Manufacturer Model RAM Screen Width

Laptop Dell Inspiron 8gb 12”

Manufacturer Model Screen Width

Panasonic Viera 52”

Title Author Manufacturer

Margin Walker Fugazi Dischord

Querying is difficult

Hard to add more types

Page 11: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

11

Complex data objects

Complex objects

Page 12: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

12

Challenges• Constant load from client• Far in excess of single server

capacity• Can never take the system

down

High transaction rates

Database

Query

QueryQuery

Query

Query

Query

QueryQuery

Page 13: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

13

Challenges• Adding more storage over time• Aging out data that’s no longer needed• Minimizing resource overhead of “cold” data

Continuous data growth

Fast Storage Archival Storage

Recent Data Old Data

Add Capacity

Page 14: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

14

High availability

Page 15: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

15

Agile development

Page 16: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

16

• Rigid schemasVariably typed data

• Normalization can be hard• Dependent on joinsComplex Objects

• Vertical scaling• Poor data locality

High transaction rate

• Difficult to maintain consistency & HA• HA a bolt-on to many RDBMSHigh Availability

• Schema changes• Monolithic data model

Agile Development

The data model is the problem

Page 17: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

17

A new data model

Page 18: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

18

var post = { author: “Jared”, date: new Date(), text: “NoSQL Now 2012”, tags: [“NoSQL”, “MongoDB”]}

> db.posts.save(post)

Documents

Page 19: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

19

>db.posts.find()

{ _id : ObjectId("4c4ba5c0672c685e5e8aabf3"), author : ”Jared", date : "Sat Jul 24 2010 19:47:11 GMT-0700 (PDT)", text : ”NoSQL Now 2012", tags : [ ”NoSQL", ”MongoDB" ] } Notes: - _id is unique, but can be anything you’d like

Queries

Page 20: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

20

Create index on any Field in Document

// 1 means ascending, -1 means descending

>db.posts.ensureIndex({author: 1})

>db.posts.find({author: ’Jared'}) { _id : ObjectId("4c4ba5c0672c685e5e8aabf3"), author : ”Jared", ... }

Indexes

Page 21: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

21

• Conditional Operators – $all, $exists, $mod, $ne, $in, $nin, $nor, $or, $size, $type– $lt, $lte, $gt, $gte

// find posts with any tags > db.posts.find( {tags: {$exists: true }} )

// find posts matching a regular expression> db.posts.find( {author: /^Jar*/i } )

// count posts by author> db.posts.find( {author: ‘Jared’} ).count()

Query Operators

Page 22: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

22

• $set, $unset, $inc, $push, $pushAll, $pull, $pullAll, $bit

> comment = { author: “Brendan”, date: new Date(), text: “I want a freakin pony”}

> db.posts.update( { _id: “...” }, $push: {comments: comment} );

Atomic Operators

Page 23: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

23

{ _id : ObjectId("4c4ba5c0672c685e5e8aabf3"), author : ”Jared", date : "Sat Jul 24 2010 19:47:11 GMT-0700 (PDT)", text : ”NoSQL Now 2012", tags : [ ”NoSQL", ”MongoDB" ], comments : [

{author : "Brendan",date : "Sat Jul 24 2010 20:51:03 GMT-0700 (PDT)",text : ”I want a freakin pony"

} ]}

Nested Documents

Page 24: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

24

// Index nested documents> db.posts.ensureIndex( “comments.author”:1 )db.posts.find({‘comments.author’:’Brendan’})

// Index on tags> db.posts.ensureIndex( tags: 1)> db.posts.find( { tags: ’MongoDB’ } )

// geospatial index> db.posts.ensureIndex( “author.location”: “2d” )> db.posts.find( “author.location” : { $near : [22,42] } )

Index on Nested Fields

Page 25: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

25

db.posts.aggregate( { $project : { author : 1, tags : 1, } }, { $unwind : “$tags” }, { $group : { _id : { tags : 1 }, authors : {

$addToSet : “$author” } } });

Aggregation

Page 26: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

26

It’s highly available

Page 27: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

27

Replica Sets

Primary

Secondary

Secondary

Asynchronous Replication

Read

Write

Read

Read

Driv

er

Page 28: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

28

Replica Sets

Primary

Secondary

Secondary

Read

Read

Driv

er

Page 29: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

29

Replica Sets

Primary

Primary

Secondary

Read

Write

Read

AutomaticLeader Election

Driv

er

Page 30: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

30

Replica Sets

Secondary

Primary

Secondary

Read

Write

Read

Read

Driv

er

Page 31: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

31

With tunable consistency

Page 32: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

32

Strong Consistency

Primary

Secondary

Secondary

Read

Write

Driv

er

Page 33: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

33

Eventual Consistency

Primary

Secondary

Secondary

Read

Write

Driv

er

Read

Page 34: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

34

Durability

Page 35: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

35

Durability

Fire and forgetWait for error Wait for fsyncWait for journal sync Wait for replication

Page 36: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

36

Fire and forget

Driver Primary

write

apply in memory

Page 37: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

37

Get last error

Driver Primary

getLastErrorapply in memory

write

Page 38: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

38

Wait for Journal Sync

Driver Primary

getLastErrorapply in memory

write

j:trueWrite to journal

Page 39: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

39

Wait for replication

Driver Primary

getLastErrorapply in memory

write

w:2

Secondary

replicate

Page 40: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

40

Value Meaning<n:integer> Replicate to N members of replica set“majority” Replicate to a majority of replica set

members<m:modeName> Use custom error mode name

Write Concern Options

Page 41: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

41

{ _id: “someSet”, members: [ { _id:0, host:”A”, tags: { dc: “ny”}}, { _id:1, host:”B”, tags: { dc: “ny”}}, { _id:2, host:”C”, tags: { dc: “sf”}}, { _id:3, host:”D”, tags: { dc: “sf”}}, { _id:4, host:”E”, tags: { dc: “cloud”}}, settings: { getLastErrorModes: { veryImportant: { dc: 3 }, sortOfImportant: { dc: 2 } } } }

Tagging

These are the modes you can

use in write concern

Page 42: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

42

• Between 0..1000• Highest member that is up to date wins

– Up to date == within 10 seconds of primary• If a higher priority member catches up, it will force election

and win

Priorities

Primarypriority = 3

Secondary

priority = 2

Secondary

priority = 1

Page 43: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

43

• Lags behind master by configurable time delay • Automatically hidden from clients• Protects against operator errors

– Accidentally delete database – Application corrupts data

Slave Delay

Page 44: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

44

• Vote in elections• Don’t store a copy of data • Use as tie breaker

Arbiters

Page 45: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

45

Single Server

Data Center

Primary

Page 46: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

46

Replica set

Data Center

Primary Secondary

Secondary

Zone 1 Zone 2 Zone 3

Page 47: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

47

Backup Node

Data Center

Primary Secondary

hidden = true

Secondary

backups

Zone 1 Zone 2 Zone 3

Page 48: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

48

Disaster Recovery

Active Data Center Standby Data Center

Primarypriority = 1

Secondary

priority = 1

Secondary

priority = 0

Zone 1 Zone 2

Page 49: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

49

West Coast DC Central DC East Coast DC

Multi Data Center

Secondary

priority = 1

Abiter

Primarypriority = 2

Secondary

priority = 2

Secondary

priority = 1

Zone 1

Zone 2

Zone 1

Zone 2

Page 50: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

50

Sharding

Page 51: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

51

Shard

Architecture

client client client client

mongos mongosconfig

config

config

mongod

mongod

mongod

Shard

mongod

mongod

mongod

Shard

mongod

mongod

mongod

Config Servers

Page 52: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

52

Keys

{ name: “Jared”, email: “[email protected]”,}{ name: “Scott”, email: “[email protected]”,}{ name: “Dan”, email: “[email protected]”,}

> db.runCommand( { shardcollection: “test.users”, key: { email: 1 }} )

Page 53: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

53

Chunks

-∞ +∞

Page 55: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

55

Chunks

-∞ +∞

[email protected]

[email protected]

[email protected]

Split!

Page 56: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

56

Chunks

-∞ +∞

[email protected]

[email protected]

[email protected]

Split!This is a chunk

This is a chunk

Page 59: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

59

Chunks

-∞ +∞

[email protected]

[email protected]

[email protected]

Split!

Page 60: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

60

Chunks

Stored in the config serversCached in MongoS Used to route requests and keep cluster balanced

Min Key Max Key Shard

-∞ [email protected] 1

[email protected] [email protected] 1

[email protected] [email protected] 1

[email protected] +∞ 1

Page 61: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

61

Balancing

Shard 1 Shard 2 Shard 3 Shard 4

5

9

1

6

10

2

7

11

3

8

12

4

17

21

13

18

22

14

19

23

15

20

24

16

29

33

25

30

34

26

31

35

27

32

36

28

41

45

37

42

46

38

43

47

39

44

48

40

mongos

balancerconfig

config

config

Chunks!

Page 62: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

62

Balancing

mongos

balancerconfig

config

config

Shard 1 Shard 2 Shard 3 Shard 4

5

9

1

6

10

2

7

11

3

8

12

4

21 22 23 24 33 34 35 36 45 46 47 48

ImbalanceImbalance

Page 63: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

63

Balancing

mongos

balancer

Move chunk 1 to Shard 2

config

config

config

Shard 1 Shard 2 Shard 3 Shard 4

5

9

1

6

10

2

7

11

3

8

12

4

21 22 23 24 33 34 35 36 45 46 47 48

Page 64: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

64

Balancing

mongos

balancerconfig

config

config

Shard 1 Shard 2 Shard 3 Shard 4

5

9

6

10

2

7

11

3

8

12

4

21 22 23 24 33 34 35 36 45 46 47 48

1

Page 65: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

65

Balancing

mongos

balancer

Chunk 1 now lives on Shard 2

config

config

config

Shard 1 Shard 2 Shard 3 Shard 4

5

9

16

10

2

7

11

3

8

12

4

21 22 23 24 33 34 35 36 45 46 47 48

Page 66: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

66

Queries

By Shard Key Routed db.users.find( {email: “[email protected]”})

Sorted by shard key

Routed in order db.users.find().sort({email:-1})

Find by non shard key

Scatter Gather db.users.find({state:”CA”})

Sorted by non shard key

Distributed merge sort

db.users.find().sort({state:1})

Page 67: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

67

Writes

Inserts Requires shard key

db.users.insert({ name: “Jared”, email: “[email protected]”})

Removes Routed db.users.delete({ email: “[email protected]”})

Scattered db.users.delete({name: “Jared”})

Updates Routed db.users.update( {email: “[email protected]”}, {$set: { state: “CA”}})

Scattered db.users.update( {state: “FZ”}, {$set:{ state: “CA”}}, false, true )

Page 68: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

68

Routed Request

mongos

Shard 1 Shard 2 Shard 3

1

2

3

41. Query arrives at

MongoS2. MongoS routes query

to a single shard3. Shard returns results

of query4. Results returned to

client

Page 69: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

69

Scatter Gather

mongos

Shard 1 Shard 2 Shard 3

1

4 1. Query arrives at MongoS

2. MongoS broadcasts query to all shards

3. Each shard returns results for query

4. Results combined and returned to client2 2

33

2

3

Page 70: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

70

Distributed Merge Sort

mongos

Shard 1 Shard 2 Shard 3

1

3

6 1. Query arrives at MongoS

2. MongoS broadcasts query to all shards

3. Each shard locally sorts results

4. Results returned to mongos

5. MongoS merge sorts individual results

6. Combined sorted result returned to client

2 2

3 3

4 4

5

2

4

Page 71: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

71

Use cases

Page 72: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

72

Sample Use Cases

User Data Management High Volume Data Feeds

w

Content Management Operational Intelligence Meta Data Management

Page 73: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

73

• More machines, more sensors, more data

• Variably structured

Machine Generated

Data

• High frequency tradingStock Market Data

• Multiple sources of data• Each changes their format

constantly

Social Media Firehose

High Volume Data Feeds

Page 74: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

74

High Volume Data Feed

Data Sources

Asynchronous writes

Flexible document model can adapt to changes in sensor

format

Write to memory with periodic disk flush

Data SourcesData

SourcesData Sources

Scale writes over multiple shards

Page 75: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

75

• Large volume of state about users• Very strict latency requirementsAd Targeting

• Expose report data to millions of customers• Report on large volumes of data• Reports that update in real time

Real time dashboards

• What are people talking about?

Social Media

Monitoring

Operational Intelligence

Page 76: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

76

Operational Intelligence

Dashboards

API

Low latency reads Parallelize queries across replicas and

shards

In database aggregation

Flexible schema adapts to changing

input dataCan use same cluster to collect, store, and

report on data

Page 77: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

77

Intuit hosts more than 500,000 websites

wanted to collect and analyze data to recommend conversion and lead generation improvements to customers.

With 10 years worth of user data, it took several days to process the information using a relational database.

Problem

Intuit hosts more than 500,000 websites

wanted to collect and analyze data to recommend conversion and lead generation improvements to customers.

With 10 years worth of user data, it took several days to process the information using a relational database.

Why MongoDB In one week Intuit was able to

become proficient in MongoDB development

Developed application features more quickly for MongoDB than for relational databases

MongoDB was 2.5 times faster than MySQL

Impact

Intuit relies on a MongoDB-powered real-time analytics tool for small businesses to derive interesting and actionable patterns from their customers’ website traffic

We did a prototype for one week, and within one week we had made big progress. Very big progress. It was so amazing that we decided, “Let’s go with this.” -Nirmala Ranganathan, Intuit

Page 78: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

78

Behavioral Profiles

1

2

3

See Ad

See Ad

4

Click

Convert

{ cookie_id: “1234512413243”, advertiser:{ apple: { actions: [ { impression: ‘ad1’, time: 123 }, { impression: ‘ad2’, time: 232 }, { click: ‘ad2’, time: 235 }, { add_to_cart: ‘laptop’, sku: ‘asdf23f’, time: 254 }, { purchase: ‘laptop’, time: 354 } ] } }}

Rich profiles collecting multiple complex actions

Scale out to support high throughput of activities tracked

Indexing and querying to support matching, frequency

capping

Dynamic schemas make it easy to track

vendor specific attributes

Page 79: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

79

• Meta data about artifacts • Content in the library

Data Archiving

• Have data sources that you don’t have access to

• Stores meta-data on those stores and figure out which ones have the content

Information discovery

• Retina scans• Finger printsBiometrics

Meta Data Management

Page 80: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

80

Meta data

{ ISBN: “00e8da9b”, type: “Book”, country: “Egypt”, title: “Ancient Egypt”}

{ type: “Artefact”, medium: “Ceramic”, country: “Egypt”, year: “3000 BC”}

Flexible data model for similar, but

different objects

Indexing and rich query API for easy

searching and sortingdb.archives.

find({ “country”: “Egypt” });

Page 81: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

81

Managing 20TB of data (six billion images for millions of customers) partitioning by function.

Home-grown key value store on top of their Oracle database offered sub-par performance

Codebase for this hybrid store became hard to manage

High licensing, HW costs

Problem

JSON-based data structure Provided Shutterfly with an

agile, high performance, scalable solution at a low cost.

Works seamlessly with Shutterfly’s services-based architecture

Why MongoDB 500% cost reduction and 900%

performance improvement compared to previous Oracle implementation

Accelerated time-to-market for nearly a dozen projects on MongoDB

Improved Performance by reducing average latency for inserts from 400ms to 2ms.

Impact

Shutterfly uses MongoDB to safeguard more than six billion images for millions of customers in the form of photos and videos, and turn everyday pictures into keepsakes

The “really killer reason” for using MongoDB is its rich JSON-based data structure, which offers Shutterfly an agile approach to develop software. With MongoDB, the Shutterfly team can quickly develop and deploy new applications, especially Web 2.0 and social features. -Kenny Gorman, Director of Data Services

Page 82: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

82

• Comments and user generated content

• Personalization of content, layoutNews Site

• Generate layout on the fly for each device that connects

• No need to cache static pages

Multi-Device rendering

• Store large objects• Simple modeling of metadataSharing

Content Management

Page 83: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

83

Content Management

{ camera: “Nikon d4”, location: [ -122.418333, 37.775 ] }

{ camera: “Canon 5d mkII”, people: [ “Jim”, “Carol” ], taken_on: ISODate("2012-03-07T18:32:35.002Z")}

{ origin: “facebook.com/photos/xwdf23fsdf”, license: “Creative Commons CC0”, size: { dimensions: [ 124, 52 ], units: “pixels” }}

Flexible data model for similar, but

different objects

Horizontal scalability for large data sets

Geo spatial indexing for location based

searchesGridFS for large object storage

Page 84: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

84

Analyze a staggering amount of data for a system build on continuous stream of high-quality text pulled from online sources

Adding too much data too quickly resulted in outages; tables locked for tens of seconds during inserts

Initially launched entirely on MySQL but quickly hit performance road blocks

Problem

Life with MongoDB has been good for Wordnik. Our code is faster, more flexible and dramatically smaller. Since we don’t spend time worrying about the database, we can spend more time writing code for our application. -Tony Tam, Vice President of Engineering and Technical Co-founder

Migrated 5 billion records in a single day with zero downtime

MongoDB powers every website requests: 20m API calls per day

Ability to eliminated memcached layer, creating a simplified system that required fewer resources and was less prone to error.

Why MongoDB Reduced code by 75%

compared to MySQL Fetch time cut from 400ms to

60ms Sustained insert speed of 8k

words per second, with frequent bursts of up to 50k per second

Significant cost savings and 15% reduction in servers

Impact

Wordnik uses MongoDB as the foundation for its “live” dictionary that stores its entire text corpus – 3.5T of data in 20 billion records

Page 85: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

85

• Scale out to large graphs • Easy to search and

process

Social Graphs

• Authentication, Authorization and Accounting

Identity Management

Identity Management

Page 86: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

86

Social Graph

Social Graphs

Documents enable disk locality of all

profile data for a user

Sharding partitions user profiles across

available servers

Native support for Arrays makes it easy to store connections

inside user profile

Page 87: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

87

Review

Page 88: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

88

Data modeling is hard

• Variety, Velocity and Volume make it difficult • Documents are easier for many use cases

Page 89: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

89

• Distributed by default• High availability• Cloud deployment

Modern deployments are hard

Page 90: MongoDB at NoSQL Now! 2012: Benefits and Challenges of Using MongoDB in the Enterprise

90

• Document oriented data model • Highly available deployments• Strong consistency model• Horizontally scalable architecture

MongoDB is better