Introduction to MongoDB
-
Upload
vladik-khononov -
Category
Technology
-
view
78 -
download
0
Transcript of Introduction to MongoDB
![Page 1: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/1.jpg)
MongoDB
![Page 2: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/2.jpg)
What is a document?
• MS Word file stored in Sharepoint
• JSON or XML
![Page 3: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/3.jpg)
What is a document?
{“campaign_id”: 12,“created_on”: ISODate("2013-04-08T18:10:48Z")“name”: “Trade LG”,“published”: true,“status_id”: 2
}
![Page 4: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/4.jpg)
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” ]
}
![Page 5: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/5.jpg)
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”
}]
}
![Page 6: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/6.jpg)
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 }
]}
]}
![Page 7: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/7.jpg)
Indexes
• ensureIndex( { “created_on”:1 } )
• ensureIndex( { “published”: 1, “status_id”: 1} )
• ensureIndex( { “keywords”: 1} )
• ensureIndex( { “placements.funnels.published”: 1 } )
![Page 8: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/8.jpg)
Querying
• Query by example
• find({“campaign_id”: 12})
• find({ “published”: true, “created_on”: { $gt: ISODate("2013-04-01") }});
![Page 9: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/9.jpg)
Scalability
• Horizontal
• Master/Slave replication
• Sharding
![Page 10: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/10.jpg)
Read Optimization
![Page 11: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/11.jpg)
Write Optimization
![Page 12: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/12.jpg)
Backup Strategies
• Replication
• Files backup
• mongodump + mongorestore
• Journal backup
![Page 13: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/13.jpg)
Deployment Options
• Hosted solutions
• Single node
• Replica set
• Replication across data centers
![Page 14: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/14.jpg)
Who uses MongoDB?
![Page 15: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/15.jpg)
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$)
![Page 16: Introduction to MongoDB](https://reader033.fdocuments.us/reader033/viewer/2022052623/559c1d1c1a28abce298b457c/html5/thumbnails/16.jpg)