Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
mongodb_web_application_-_MongoDC_2011.ppt.pdf
Search
mongodb
July 11, 2011
Programming
2
460
mongodb_web_application_-_MongoDC_2011.ppt.pdf
mongodb
July 11, 2011
Tweet
Share
More Decks by mongodb
See All by mongodb
NoSQL Now! 2012
mongodb
18
3.4k
MongoDB 2.2 At the Silicon Valley MongoDB User Group
mongodb
9
1.4k
Turning off the LAMP Hunter Loftis, Skookum Digital Works
mongodb
2
1.5k
Mobilize Your MongoDB! Developing iPhone and Android Apps in the Cloud Grant Shipley, Red Hat
mongodb
0
530
Beanstalk Data - MongoDB In Production Chris Siefken, CTO Beanstalk Data
mongodb
0
540
New LINQ support in C#/.NET driver Robert Stam, 10gen
mongodb
9
41k
Welcome and Keynote Aaron Heckman, 10gen
mongodb
0
510
Webinar Introduction to MongoDB's Java Driver
mongodb
1
1.2k
Webinar Intro to Schema Design
mongodb
4
1.8k
Other Decks in Programming
See All in Programming
Kotlin Multiplatform Meetup - Compose Multiplatform 외부 의존성 아키텍처 설계부터 운영까지
wisemuji
0
160
DevFest Android in Korea 2025 - 개발자 커뮤니티를 통해 얻는 가치
wisemuji
0
180
Go コードベースの構成と AI コンテキスト定義
andpad
0
150
QAフローを最適化し、品質水準を満たしながらリリースまでの期間を最短化する #RSGT2026
shibayu36
0
1.6k
Python札幌 LT資料
t3tra
7
1.1k
脳の「省エネモード」をデバッグする ~System 1(直感)と System 2(論理)の切り替え~
panda728
PRO
0
130
チームをチームにするEM
hitode909
0
440
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
6
1.6k
[AtCoder Conference 2025] LLMを使った業務AHCの上⼿な解き⽅
terryu16
6
1k
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
150
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
120
JETLS.jl ─ A New Language Server for Julia
abap34
2
470
Featured
See All Featured
Claude Code のすすめ
schroneko
67
210k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
140
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
120
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
74
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
59
Raft: Consensus for Rubyists
vanstee
141
7.3k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
110
Everyday Curiosity
cassininazir
0
120
Digital Ethics as a Driver of Design Innovation
axbom
PRO
0
140
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.5k
Transcript
http://mongodb.org http://10gen.com Building applications with MongoDB – An introduction MongoDC
– June 27, 2011 Nosh Petigara
[email protected]
@noshinosh
Today’s Talk • MongoDB: Data modeling, queries, geospatial, updates, map reduce
• Using a location-based app as an example • Example Works in MongoDB JS shell
Application Goals Places Check ins (1) Q: Current location A:
Places near location (2) Add user generated content (3) Record user checkins (4) Stats about checkins
Documents doc1 = { _id: 4b97e62bf1d8c7152c9ccb74, key1: value1, key2:
value2, key3: {..., ..., ...}, key4: [..., ..., ] }
Collections doc1, doc2, doc3 Places Users Checkins doc3, doc4, doc5
doc6, doc7, doc8
place1 = { name: "10gen HQ”, address: ”134 5th
Avenue 3rd Floor”, city: "New York”, zip: "10011” } db.places.find({zip:”10011”}).limit(10) Places v1
place1 = { name: "10gen HQ”, address: "17 West
18th Street 8th Floor”, city: "New York”, zip: "10011”, tags: [“business”, “recommended”] } db.places.find({zip:”10011”, tags:”business”}) Places v2
place1 = { name: "10gen HQ”, address: "17 West
18th Street 8th Floor”, city: "New York”, zip: "10011”, tags: [“business”, “cool place”], latlong: [40.0,72.0] } db.places.ensureIndex({latlong:”2d”}) db.places.find({latlong:{$near:[40,70]}}) Places v3
place1 = { name: "10gen HQ”, address: "17 West
18th Street 8th Floor”, city: "New York”, zip: "10011”, latlong: [40.0,72.0], tags: [“business”, “cool place”], tips: [ {user:"nosh", time:6/26/2010, tip:"stop by for office hours on Wednesdays from 4-6pm"}, {.....}, {.....} ] } Places v4
Creating your indexes db.places.ensureIndex({tags:1}) db.places.ensureIndex({name:1}) db.places.ensureIndex({latlong:”2d”}) Finding places: db.places.find({latlong:{$near:[40,70]}}) With
regular expressions: db.places.find({name: /^typeaheadstring/) By tag: db.places.find({tags: “business”}) Querying your Places
Initial data load: db.places.insert(place1) Updating tips: db.places.update({name:"10gen HQ"}, {$push :{tips:
{user:"nosh", time:6/26/2010, tip:"stop by for office hours on Wednesdays from 4-6"}}}}
$set, $unset, $rename $push, $pop, $pull, $addToSet $inc Atomic Updates
Application Goals Places Check ins (1) Q: Current location A:
Places near location (2) Add user generated content (3) Record user checkins (4) Stats about checkins
user1 = { name: “nosh” email: “
[email protected]
”, . . .
checkins: [4b97e62bf1d8c7152c9ccb74, 5a20e62bf1d8c736ab] } checkins [] = ObjectId reference to checkin collection Users
checkin1 = { place: “10gen HQ”, ts: 6/7/2011 10:12:00, userId:
<objectid of user> } Check-in = 2 ops Insert check in object [checkin collection] Update ($push) user object [user collection] Indexes: db.checkins.ensureIndex({place:1, ts:1}) db.checkins.ensureIndex({ts:1}) Checkins
Application Goals Places Check ins (1) Q: Current location A:
Places near location (2) Add user generated content (3) Record user checkins (4) Stats about checkins
Simple Stats db.checkins.find({place: “10gen HQ”) db.checkins.find({place: “10gen HQ”}) .sort({ts:-1}).limit(10) db.checkins.find({place:
“10gen HQ”, ts: {$gt: midnight}}).count() db.checkins.find().sort(ts:-1)}.limit(50)
Stats with MapReduce mapFunc = function() { emit(this.place, 1);} reduceFunc
= function(key, values) { return Array.sum(values); } db.checkins.mapReduce(mapFunc,reduceFunc, {query: {timestamp: {$gt:nowminus3hrs}}, out: “result”}) result = [{_id:”10gen HQ”, value: 17}, {…..}, {….}] db.result.find({ value: {$gt: 15}})
Application Goals Places Check ins (1) Q: Current location A:
Places near location (2) Add user generated content (3) Record user checkins (4) Stats about checkins
Single Master Deployments Primary/Master Secondary/Slave • Configure as a replica set
for automated failover • Add more secondaries to scale reads
Auto Sharded Deployment Primary/Master Secondary/Slave MongoS • Autosharding distributes data among
two or more replica sets • Mongo Config Server(s) handles distribution & balancing • Transparent to applications Mongo Config
Use Cases • RDBMS replacement for high-traffic web applications • Content Management-type
applications • Real-time analytics • High-speed data logging Web 2.0, Media, SaaS, Gaming, Finance, Telecom, Healthcare
Nosh Petigara
[email protected]
Director of Product Strategy, 10gen http://mongodb.org http://10gen.com
- We are hiring! - @mongodb
[email protected]
@noshinosh
MongoDB in Production