SlideShare a Scribd company logo
Building a Social Network with MongoDB
Brian Zambrano
MongoSV
December 3, 2010
1
Friday, December 3, 2010
Eventbrite Brand Tenets
2
Friday, December 3, 2010
Eventbrite Brand Tenets
3
Friday, December 3, 2010
Social Recommendations
4
Friday, December 3, 2010
Eventbriteʼs Social Graph
5
Friday, December 3, 2010
Eventbriteʼs Social Graph
6
Friday, December 3, 2010
Neighbors
7
Friday, December 3, 2010
Challenges
• Dynamic
• Neighbors change often
• Neighborsʼ events change often
• Flexibility
• Want to incorporate other social graphs
• Product may evolve quickly
• Performance
• We need really fast reads
• Frequent writes
8
Friday, December 3, 2010
Why MongoDB?
• Performance
• Flexible schema design
• Easy to work with
• We felt comfortable MongoDB would mature as
our needs became more demanding
9
Friday, December 3, 2010
Providing Recommendations
1. User visits http://eventbrite.com/mytickets/
2. Fetch neighbors
3. Fetch neighborsʼ events
4. Score each possible event
5. Return recommendations
10
Friday, December 3, 2010
MongoDB setup
• One non-sharded replica set
• Two DBs on Large EC2 instances
• One arbiter
• Three collections
• Users
• Events
• Orders
11
Friday, December 3, 2010
User Data in MongoDB
12
{ "_id": 4558992,
}
Unique User Id
Friday, December 3, 2010
User Data in MongoDB
13
{ "_id": 4558992,
"events" : {
"all_ids": [ 116706, 179487, 16389, 827496 ],
"curr_ids": [ 827496 ],
},
}
Past and current
attendance
Friday, December 3, 2010
User Data in MongoDB
14
{ "_id": 4558992,
"events" : {
"all_ids": [ 116706, 179487, 16389, 827496 ],
"curr_ids": [ 827496 ],
},
"nns" : [
[ 2816442, 0.2 ],
[ 1615962, 0.047619047619047616 ],
],
} Nearest neighbors
(user_id, score)
Friday, December 3, 2010
User Data in MongoDB
15
{ "_id": 4558992,
"events" : {
"all_ids": [ 116706, 179487, 16389, 827496 ],
"curr_ids": [ 827496 ],
},
"nns" : [
[ 2816442, 0.2 ],
[ 1615962, 0.047619047619047616 ],
],
"fb" : {
"_id" : 4808871,
"name" : "Brian Zambrano",
"location" : "San Francisco, California",
"friends" : [ 568876525, 569507467, 569559792 ],
},
}
Facebook data
Friday, December 3, 2010
MongoDB Indexes
16
{ "_id": 4558992,
"events" : {
"all_ids": [ 116706, 179487, 16389, 827496 ],
"curr_ids": [ 827496 ],
},
"nns" : [
[ 2816442, 0.2 ],
[ 1615962, 0.047619047619047616 ],
],
"fb" : {
"_id" : 4808871,
"name" : "Brian Zambrano",
"location" : "San Francisco, California",
"friends" : [ 568876525, 569507467, 569559792],
},
}
Friday, December 3, 2010
Events Collection
> db.events.findOne({_id: 799177})
{
"_id" : 799177,
"uid" : 2989008,
"title" : "MongoSV",
"venue" : {
"loc" : [
37.413042,
-122.071106
],
"state" : "CA",
"id" : 508093,
"city" : "Mountain View"
},
"logo" : "758915938.png",
"shortname" : "mongosv",
"start_date" : "Fri Dec 03 2010 01:00:00 GMT-0800 (PST)"
}
17
Friday, December 3, 2010
Orders Collection
> db.orders.find({_eid: 799177})
{ "_id" : 17464215, "_uid" : 1111195, "_eid" : 799177 }
{ "_id" : 17575729, "_uid" : 6970539, "_eid" : 799177 }
{ "_id" : 17582343, "_uid" : 3092687, "_eid" : 799177 }
{ "_id" : 17588693, "_uid" : 2255017, "_eid" : 799177 }
{ "_id" : 17589589, "_uid" : 6976917, "_eid" : 799177 }
{ "_id" : 17601979, "_uid" : 885441, "_eid" : 799177 }
{ "_id" : 17603085, "_uid" : 2500199, "_eid" : 799177 }
{ "_id" : 17608289, "_uid" : 6984367, "_eid" : 799177 }
{ "_id" : 17681965, "_uid" : 628459, "_eid" : 799177 }
{ "_id" : 17684489, "_uid" : 7017999, "_eid" : 799177 }
{ "_id" : 17689673, "_uid" : 7020133, "_eid" : 799177 }
{ "_id" : 17728267, "_uid" : 7036607, "_eid" : 799177 }
has more
18
Friday, December 3, 2010
Recommended Events Query
Two + n queries
1. Get neighbors
nns = db.users.find({_id : {$in : user.nn_ids}})
2. Get possible event recommendations:
db.events.find({_id : {$in : nns.events.all}})
n.For each event, get total attendee count
db.orders.find({_eid : event_id})
19
Friday, December 3, 2010
Recommended Events Query
Two + n queries
1. Get neighbors
nns = db.users.find({_id : {$in : user.nn_ids}})
2. Get possible event recommendations:
db.events.find({_id : {$in : nns.events.all}})
n.For each event, get total attendee count
db.orders.find({_eid : event_id})
20
Optimization opportunity:
Embed orders in Event records
Friday, December 3, 2010
Updating Neighbors
Two queries, one update
1. Get all orders for a userʼs past events:
uids = db.orders.find({_id : {$in : user.events.all}})
2. Get all neighbors:
nns = db.users.find({_id : {$in : uids}})
➡Score neighbors
3. Update nn_ids
db.users.update({_id : uid},
{$set : {nn_ids: nn}})
21
Friday, December 3, 2010
Facebook Friendʼs Events
Two queries
1. Get FB friends
db.users.find({fb._id : {$in : fb.friends}})
2. Get events FB friends are attending
db.events.find({_id : {$in : fb_friends_events}})
22
Friday, December 3, 2010
The Future
• Incorporate other social networks
• Iterate scoring algorithm
• Count recommendation impressions
23
Friday, December 3, 2010
Weʼre hiring!
http://www.eventbrite.com/jobs/
24
Friday, December 3, 2010
Thanks!
Brian Zambrano <brianz@eventbrite.com>
Eventbriteʼs new Facebook recommendations power
social event discovery: http://bit.ly/gRVS7I
Social Commerce: A First Look at the Numbers:
http://bit.ly/gXeg9Q
25
Friday, December 3, 2010

More Related Content

PDF
Link Analysis for Web Information Retrieval
PDF
Personalized search
PPT
Online Mobile Shopping
PDF
Indian Matrimonial Portals
PPTX
Online earning
PDF
Library management system
PPTX
Seo presentation
PPT
Naukri presentation
Link Analysis for Web Information Retrieval
Personalized search
Online Mobile Shopping
Indian Matrimonial Portals
Online earning
Library management system
Seo presentation
Naukri presentation

What's hot (20)

PDF
Learning to rank search results
PDF
SEO & Social Media
PPTX
On page off-page seo points
PPTX
What is the best steps for seo ? ppt
ODP
Introduction to Web Scraping using Python and Beautiful Soup
PPT
Seo Presentation for Beginners, Complete SEO ppt,
PPTX
Web Mining & Text Mining
PPTX
Final Presentation on Online Library Management
PPTX
Do follow and no-follow link
PPT
Library Management System Project
PPT
Library Management System
PPT
Local SEO Presentation
PDF
Web scraping in python
PPTX
Boolean Training
PPTX
Sourcing Innovation Lab Ryan Gillis
PPTX
IMPORTANCE OF HAVING A WEBSITE PRESENTATION
PPTX
Dbms project.ppt
PDF
Representation Learning of Text for NLP
PPT
Ats ppt
PPTX
F16 cs15 free lancing (1)
Learning to rank search results
SEO & Social Media
On page off-page seo points
What is the best steps for seo ? ppt
Introduction to Web Scraping using Python and Beautiful Soup
Seo Presentation for Beginners, Complete SEO ppt,
Web Mining & Text Mining
Final Presentation on Online Library Management
Do follow and no-follow link
Library Management System Project
Library Management System
Local SEO Presentation
Web scraping in python
Boolean Training
Sourcing Innovation Lab Ryan Gillis
IMPORTANCE OF HAVING A WEBSITE PRESENTATION
Dbms project.ppt
Representation Learning of Text for NLP
Ats ppt
F16 cs15 free lancing (1)
Ad

Viewers also liked (20)

PDF
1 Page Salary Negotiation Cheat Sheet
PDF
Statistics to Know for Case Interview
PDF
PM interview questions book pdf
PDF
Google Product Manager Interview Cheat Sheet
PDF
Salary Negotiation Cheat Sheet
PDF
What Game Developers Look for in a New Graduate: Interviews and Surveys at On...
PDF
A gentle introduction to algorithm complexity analysis
PDF
Creating social features at BranchOut using MongoDB
PDF
Book Summary: Secrets of the Product Manager Interview
PPTX
MongoDB Best Practices
PPTX
MongoDB Schema Design and its Performance Implications
PDF
Amazon Product Manager Interview Cheat Sheet
PDF
Facebook Rotational Product Manager Interview: Jewel Lim's Tips on Getting an...
PPTX
How to Ace the Product Management Interview, Product Camp Seattle Oct 2013
PDF
Book Summary: Decode and Conquer by Lewis C. Lin
PDF
Facebook Product Manager Interview Cheat Sheet
PDF
Google product manager interview questions answers
PDF
100 product management interview questions and answers pdf
PPTX
Cracking the Product Manager Interview
PPTX
MongoDB Schema Design: Four Real-World Examples
1 Page Salary Negotiation Cheat Sheet
Statistics to Know for Case Interview
PM interview questions book pdf
Google Product Manager Interview Cheat Sheet
Salary Negotiation Cheat Sheet
What Game Developers Look for in a New Graduate: Interviews and Surveys at On...
A gentle introduction to algorithm complexity analysis
Creating social features at BranchOut using MongoDB
Book Summary: Secrets of the Product Manager Interview
MongoDB Best Practices
MongoDB Schema Design and its Performance Implications
Amazon Product Manager Interview Cheat Sheet
Facebook Rotational Product Manager Interview: Jewel Lim's Tips on Getting an...
How to Ace the Product Management Interview, Product Camp Seattle Oct 2013
Book Summary: Decode and Conquer by Lewis C. Lin
Facebook Product Manager Interview Cheat Sheet
Google product manager interview questions answers
100 product management interview questions and answers pdf
Cracking the Product Manager Interview
MongoDB Schema Design: Four Real-World Examples
Ad

Similar to Building a Social Network with MongoDB (20)

PDF
Building a Social Network with MongoDB
PPTX
User Data Management with MongoDB
PDF
Awesome Tools 2017
PPTX
Big Data Analytics 1: Driving Personalized Experiences Using Customer Profiles
PDF
MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...
PPTX
Back to Basics Webinar 3: Schema Design Thinking in Documents
PPTX
Back to Basics Webinar 3 - Thinking in Documents
PPTX
Webinar: Schema Design
PPTX
Creating a Single View Part 1: Overview and Data Analysis
PDF
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
PDF
MongoDB .local Munich 2019: Best Practices for Working with IoT and Time-seri...
PDF
MongoDB
PDF
6 things to expect when you are visualizing
PPTX
Internet of things
PPTX
Dev Jumpstart: Schema Design Best Practices
PPTX
First app online conf
PDF
Intro to MongoDB and datamodeling
PPTX
Systems of engagement
PDF
Schema Design in MongoDB - TriMug Meetup North Carolina
PDF
Data Visualization for Big Data: Experience from the Front Line
Building a Social Network with MongoDB
User Data Management with MongoDB
Awesome Tools 2017
Big Data Analytics 1: Driving Personalized Experiences Using Customer Profiles
MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...
Back to Basics Webinar 3: Schema Design Thinking in Documents
Back to Basics Webinar 3 - Thinking in Documents
Webinar: Schema Design
Creating a Single View Part 1: Overview and Data Analysis
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB .local Munich 2019: Best Practices for Working with IoT and Time-seri...
MongoDB
6 things to expect when you are visualizing
Internet of things
Dev Jumpstart: Schema Design Best Practices
First app online conf
Intro to MongoDB and datamodeling
Systems of engagement
Schema Design in MongoDB - TriMug Meetup North Carolina
Data Visualization for Big Data: Experience from the Front Line

More from Lewis Lin 🦊 (20)

PDF
Gaskins' memo pitching PowerPoint
PDF
P&G Memo: Creating Modern Day Brand Management
PDF
Jeffrey Katzenberg on Disney Studios
PDF
Carnegie Mellon MS PM Internships 2020
PDF
Gallup's Notes on Reinventing Performance Management
PDF
Twitter Job Opportunities for Students
PDF
Facebook's Official Guide to Technical Program Management Candidates
PDF
Performance Management at Google
PDF
Google Interview Prep Guide Software Engineer
PDF
Google Interview Prep Guide Product Manager
PDF
Skills Assessment Offering by Lewis C. Lin
PDF
How Men and Women Differ Across Leadership Traits
PDF
Product Manager Skills Survey
PDF
Uxpin Why Build a Design System
PDF
Sourcing on GitHub
PDF
30-Day Google PM Interview Study Guide
PDF
30-Day Facebook PM Interview Study Guide
PDF
36-Day Amazon PM Interview Study Guide
PDF
McKinsey's Assessment on PM Careers
PDF
Five Traits of Great Product Managers
Gaskins' memo pitching PowerPoint
P&G Memo: Creating Modern Day Brand Management
Jeffrey Katzenberg on Disney Studios
Carnegie Mellon MS PM Internships 2020
Gallup's Notes on Reinventing Performance Management
Twitter Job Opportunities for Students
Facebook's Official Guide to Technical Program Management Candidates
Performance Management at Google
Google Interview Prep Guide Software Engineer
Google Interview Prep Guide Product Manager
Skills Assessment Offering by Lewis C. Lin
How Men and Women Differ Across Leadership Traits
Product Manager Skills Survey
Uxpin Why Build a Design System
Sourcing on GitHub
30-Day Google PM Interview Study Guide
30-Day Facebook PM Interview Study Guide
36-Day Amazon PM Interview Study Guide
McKinsey's Assessment on PM Careers
Five Traits of Great Product Managers

Recently uploaded (20)

PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
System and Network Administration Chapter 2
PPTX
Transform Your Business with a Software ERP System
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Digital Strategies for Manufacturing Companies
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
L1 - Introduction to python Backend.pptx
PDF
AI in Product Development-omnex systems
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
System and Network Administraation Chapter 3
PPT
Introduction Database Management System for Course Database
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Nekopoi APK 2025 free lastest update
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
System and Network Administration Chapter 2
Transform Your Business with a Software ERP System
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Digital Strategies for Manufacturing Companies
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
L1 - Introduction to python Backend.pptx
AI in Product Development-omnex systems
Softaken Excel to vCard Converter Software.pdf
Odoo Companies in India – Driving Business Transformation.pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
System and Network Administraation Chapter 3
Introduction Database Management System for Course Database
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
How to Migrate SBCGlobal Email to Yahoo Easily
2025 Textile ERP Trends: SAP, Odoo & Oracle
Nekopoi APK 2025 free lastest update
Navsoft: AI-Powered Business Solutions & Custom Software Development
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
How to Choose the Right IT Partner for Your Business in Malaysia

Building a Social Network with MongoDB

  • 1. Building a Social Network with MongoDB Brian Zambrano MongoSV December 3, 2010 1 Friday, December 3, 2010
  • 8. Challenges • Dynamic • Neighbors change often • Neighborsʼ events change often • Flexibility • Want to incorporate other social graphs • Product may evolve quickly • Performance • We need really fast reads • Frequent writes 8 Friday, December 3, 2010
  • 9. Why MongoDB? • Performance • Flexible schema design • Easy to work with • We felt comfortable MongoDB would mature as our needs became more demanding 9 Friday, December 3, 2010
  • 10. Providing Recommendations 1. User visits http://eventbrite.com/mytickets/ 2. Fetch neighbors 3. Fetch neighborsʼ events 4. Score each possible event 5. Return recommendations 10 Friday, December 3, 2010
  • 11. MongoDB setup • One non-sharded replica set • Two DBs on Large EC2 instances • One arbiter • Three collections • Users • Events • Orders 11 Friday, December 3, 2010
  • 12. User Data in MongoDB 12 { "_id": 4558992, } Unique User Id Friday, December 3, 2010
  • 13. User Data in MongoDB 13 { "_id": 4558992, "events" : { "all_ids": [ 116706, 179487, 16389, 827496 ], "curr_ids": [ 827496 ], }, } Past and current attendance Friday, December 3, 2010
  • 14. User Data in MongoDB 14 { "_id": 4558992, "events" : { "all_ids": [ 116706, 179487, 16389, 827496 ], "curr_ids": [ 827496 ], }, "nns" : [ [ 2816442, 0.2 ], [ 1615962, 0.047619047619047616 ], ], } Nearest neighbors (user_id, score) Friday, December 3, 2010
  • 15. User Data in MongoDB 15 { "_id": 4558992, "events" : { "all_ids": [ 116706, 179487, 16389, 827496 ], "curr_ids": [ 827496 ], }, "nns" : [ [ 2816442, 0.2 ], [ 1615962, 0.047619047619047616 ], ], "fb" : { "_id" : 4808871, "name" : "Brian Zambrano", "location" : "San Francisco, California", "friends" : [ 568876525, 569507467, 569559792 ], }, } Facebook data Friday, December 3, 2010
  • 16. MongoDB Indexes 16 { "_id": 4558992, "events" : { "all_ids": [ 116706, 179487, 16389, 827496 ], "curr_ids": [ 827496 ], }, "nns" : [ [ 2816442, 0.2 ], [ 1615962, 0.047619047619047616 ], ], "fb" : { "_id" : 4808871, "name" : "Brian Zambrano", "location" : "San Francisco, California", "friends" : [ 568876525, 569507467, 569559792], }, } Friday, December 3, 2010
  • 17. Events Collection > db.events.findOne({_id: 799177}) { "_id" : 799177, "uid" : 2989008, "title" : "MongoSV", "venue" : { "loc" : [ 37.413042, -122.071106 ], "state" : "CA", "id" : 508093, "city" : "Mountain View" }, "logo" : "758915938.png", "shortname" : "mongosv", "start_date" : "Fri Dec 03 2010 01:00:00 GMT-0800 (PST)" } 17 Friday, December 3, 2010
  • 18. Orders Collection > db.orders.find({_eid: 799177}) { "_id" : 17464215, "_uid" : 1111195, "_eid" : 799177 } { "_id" : 17575729, "_uid" : 6970539, "_eid" : 799177 } { "_id" : 17582343, "_uid" : 3092687, "_eid" : 799177 } { "_id" : 17588693, "_uid" : 2255017, "_eid" : 799177 } { "_id" : 17589589, "_uid" : 6976917, "_eid" : 799177 } { "_id" : 17601979, "_uid" : 885441, "_eid" : 799177 } { "_id" : 17603085, "_uid" : 2500199, "_eid" : 799177 } { "_id" : 17608289, "_uid" : 6984367, "_eid" : 799177 } { "_id" : 17681965, "_uid" : 628459, "_eid" : 799177 } { "_id" : 17684489, "_uid" : 7017999, "_eid" : 799177 } { "_id" : 17689673, "_uid" : 7020133, "_eid" : 799177 } { "_id" : 17728267, "_uid" : 7036607, "_eid" : 799177 } has more 18 Friday, December 3, 2010
  • 19. Recommended Events Query Two + n queries 1. Get neighbors nns = db.users.find({_id : {$in : user.nn_ids}}) 2. Get possible event recommendations: db.events.find({_id : {$in : nns.events.all}}) n.For each event, get total attendee count db.orders.find({_eid : event_id}) 19 Friday, December 3, 2010
  • 20. Recommended Events Query Two + n queries 1. Get neighbors nns = db.users.find({_id : {$in : user.nn_ids}}) 2. Get possible event recommendations: db.events.find({_id : {$in : nns.events.all}}) n.For each event, get total attendee count db.orders.find({_eid : event_id}) 20 Optimization opportunity: Embed orders in Event records Friday, December 3, 2010
  • 21. Updating Neighbors Two queries, one update 1. Get all orders for a userʼs past events: uids = db.orders.find({_id : {$in : user.events.all}}) 2. Get all neighbors: nns = db.users.find({_id : {$in : uids}}) ➡Score neighbors 3. Update nn_ids db.users.update({_id : uid}, {$set : {nn_ids: nn}}) 21 Friday, December 3, 2010
  • 22. Facebook Friendʼs Events Two queries 1. Get FB friends db.users.find({fb._id : {$in : fb.friends}}) 2. Get events FB friends are attending db.events.find({_id : {$in : fb_friends_events}}) 22 Friday, December 3, 2010
  • 23. The Future • Incorporate other social networks • Iterate scoring algorithm • Count recommendation impressions 23 Friday, December 3, 2010
  • 25. Thanks! Brian Zambrano <brianz@eventbrite.com> Eventbriteʼs new Facebook recommendations power social event discovery: http://bit.ly/gRVS7I Social Commerce: A First Look at the Numbers: http://bit.ly/gXeg9Q 25 Friday, December 3, 2010