Transcript

MongoDB

What is a document?

• MS Word file stored in Sharepoint

• JSON or XML

What is a document?

{“campaign_id”: 12,“created_on”: ISODate("2013-04-08T18:10:48Z")“name”: “Trade LG”,“published”: true,“status_id”: 2

}

What is a document?

{“campaign_id”: 12,“created_on”: ISODate("2013-04-08T18:10:48Z")“name”: “Trade LG”,“published”: true,“status_id”: 2,“keywords”: [ “trade lg”, “yahoo”, “test” ]

}

What is a document?{

“campaign_id”: 12,“created_on”: ISODate("2013-04-08T18:10:48Z")“name”: “Trade LG [01JUL2013] [1308]”,“published”: true,“status_id”: 2,“keywords”: [ “trade lg”, “yahoo”, “test” ],“placements”: [

{ “placement_id”: 14,“name”: “[3495] [01JUL2013] ROS 20minutes 300X250”

}]

}

What is a document?{

“campaign_id”: 12,“created_on”: ISODate("2013-04-08T18:10:48Z")“name”: “Trade LG [01JUL2013] [1308]”,“published”: true,“status_id”: 2,“keywords”: [ “trade lg”, “yahoo”, “test” ],“placements”: [

{ “placement_id”: 14,“name”: “[3495] [01JUL2013] ROS 20minutes 300X250”,“funnels”: [

{ “funnel_id”: 15, “name”: “funnel_1”, “published”: true },{ “funnel_id”: 16 “name”: “funnel_2”, “published”: false },{ “funnel_id”: 17, “name”: “funnel_3”, “published”: true }

]}

]}

Indexes

• ensureIndex( { “created_on”:1 } )

• ensureIndex( { “published”: 1, “status_id”: 1} )

• ensureIndex( { “keywords”: 1} )

• ensureIndex( { “placements.funnels.published”: 1 } )

Querying

• Query by example

• find({“campaign_id”: 12})

• find({ “published”: true, “created_on”: { $gt: ISODate("2013-04-01") }});

Scalability

• Horizontal

• Master/Slave replication

• Sharding

Read Optimization

Write Optimization

Backup Strategies

• Replication

• Files backup

• mongodump + mongorestore

• Journal backup

Deployment Options

• Hosted solutions

• Single node

• Replica set

• Replication across data centers

Who uses MongoDB?

Internal POC• 24,000,000+ activities

• 11GB

• 14,500 inserts per second

• Fetch activities by user id:44,438 results, ~60ms

• Fetch activities by type name:3,585,101 results, ~6942ms

• Single server: M1-Large(300$)

top related