building social inbox, using mongodb

26
Building A Practical Social Inbox Using MongoDB Dec 9 th , 2014 10. 30 am EST #suyatiwebinar

Upload: suyati-technologies-pvt-ltd

Post on 15-Jul-2015

845 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Building Social Inbox, using MongoDB

Building A Practical Social Inbox

Using MongoDB

Dec 9th , 2014

10. 30 am EST

#suyatiwebinar

Page 2: Building Social Inbox, using MongoDB
Page 3: Building Social Inbox, using MongoDB

OUR

SPEAKER

Page 5: Building Social Inbox, using MongoDB

Introduction to MongoDB

What are Social Inboxes? What are the

different types of Social Inboxes?

Challenges in building Social Inboxes

Patterns for building Social Inboxes

Implementing a Write intensive Social

Inbox

Introduction to Mongologue

OUR

AGENDA

Page 6: Building Social Inbox, using MongoDB

Humongous Data

PERFORMANCE, AVAILABILITY, AUTO-SCALING

http://www.mongodb.org/downloads

http://try.mongodb.org

http://docs.mongodb.org/manual

MONGODB

Page 7: Building Social Inbox, using MongoDB

MongoDB stores data in the form of documents

MongoDB stores all documents in collections. Collections are analogous to tables in Relational DBs

Page 8: Building Social Inbox, using MongoDB

WHAT IS

SOCIALINBOX

Page 9: Building Social Inbox, using MongoDB

Read/Write requests Volume Performance

Real Time User Experience

CONSIDERATIONS

Page 10: Building Social Inbox, using MongoDB

Creates Posts (Write) Reads Timeline (Read) Follows Other Users Gets Followed by other Users

A USER

Page 11: Building Social Inbox, using MongoDB

Real Time Writes and Reads Sorting Posts Paging and Delivery

AN

INBOX

“An Average Tweet makes it to about 254 inboxes”

Page 12: Building Social Inbox, using MongoDB

• Duplication for performance• Parallel for scalability

THE MYTH OFNORMALIZED DATA

Page 13: Building Social Inbox, using MongoDB

Fan-out on Read Fan-out on Write Fan-out on Write with Buckets

SCHEMA

DESIGNS

Page 14: Building Social Inbox, using MongoDB

SCHEMASFan out on Read Fan out on Write

Send Message Performance

BestGood

Shard per recipientMultiple writes

Read Inbox PerformanceWorst

Broadcast all shardsRandom reads

GoodSingle shard

Random reads

Data SizeBest

Message stored onceWorst

Copy per recipient

Page 15: Building Social Inbox, using MongoDB

var user = {"name": "john", "id": 1}show collectionsdb.testUsers.save(user)show collectionsdb.testUsers.find()

SOME

CODE

Page 16: Building Social Inbox, using MongoDB

Ensuring everything's at arm's lengthLET’S TALK

SCHEMA

Page 17: Building Social Inbox, using MongoDB

Creates Posts (Write) Reads Timeline (Read) Follows Other Users Gets Followed by other Users

A USER

Page 18: Building Social Inbox, using MongoDB

var user = {"name": "john", "followers":[],"following":[]

}db.users.save(user)db.users.find()

THE

USERDOCUMENT

Page 19: Building Social Inbox, using MongoDB

var post = {"from": "john", "date":new Date(),"message":"hello"

}

THE

POSTDOCUMENT

Page 20: Building Social Inbox, using MongoDB

db.shardCollection("mongodbdays.inbox", {"recipient": 1, "sent":1})

var post = {"from": "john", "date":new Date(),"message":"hello"

}

var user = db.users.findOne({name: post.from})

for(follower in user.followers) {post.to = follower;db.inbox.insert(post)

}

CREATING A

POST

Page 21: Building Social Inbox, using MongoDB

db.inbox.find ({to: "john"}).sort({ sent:-1})

RETREIVING THE

POST

Page 22: Building Social Inbox, using MongoDB

A shard is a replica set or a single mongodthat contains a subset of the data for the sharded cluster.

SHARDS

Page 23: Building Social Inbox, using MongoDB

db.shardCollection("test.inbox", {"to": 1, "sent":1})SHARDS

Page 24: Building Social Inbox, using MongoDB

Groups Unfollow / Block Media in Posts Comments, Likes

https://github.com/suyati/mongologue

GOING

FURTHER