Social network architecture - Part 2. News feed

Preview:

Citation preview

<SOCIAL NETWORK ARCHITECTURE>@DEV ZONE

Overview architecture

Web Apps

Web Service APIs

Mobile Apps

4. Front-end

SSOUser

ranking

1. Core User

User Data Storage

Real-time Notification

News Feed

2. User Activity System

User Activity Storage

3. Others

Real-time Chat

Search System Suggestion System

3. Big Data System

Big Data Storage

External Apps

Service Data

UserAdministrator

Notification & Feed System –NFS (Need For Speed :D)

2. NFS: Definition

• Notification: to owner

• News feed: to owner connection

2. NFS: Process

STORAGE

Activities

Connections

AGGREGATION

Feed ItemsNotifications

DISPLAY

HTMLsJSONsAJAXs

2. NFS: STORAGE

• Actions• Ronaldo followed Messi

• Ronaldo tagged Messi on a Post

Subject Verb Object Target

UserGroup

FollowAdd (friend, member)JoinPostLikeShareCommentTagUpdate

UserGroupContent

UserGroupContent

2. NFS: STORAGE

• Connections• Ronaldo follow Messi

• Ronaldo post a Content

• Ronaldo comment a Content

• Ronaldo join a Group

• …

Content

Group

User

User

post, follow, tag, comment

2. NFS: STORAGE

• Store actions -> activities• [owner, [{ subject, verb, object, target }]]

• Examples:• Ronaldo followed Messi

• [ Ronaldo, [{ Ronaldo, follow, Messi, null }]]• Ronaldo added friend to Messi

• [ Ronaldo, [{ Ronaldo, friend, Messi, null }]]• [Messi, [{ Ronaldo, friend, Messi, null }]]

• Ronaldo post Content on a Group• [ Ronaldo, [{ Ronaldo, post, Content, Group }]]• [Content, [{ Ronaldo, post, Content, Group }]]• [ Group, [{ Ronaldo, post, Content, Group }]]

• Ronaldo tagged Messi on a Post• [ Ronaldo, [{ Ronaldo, tag, Messi, Post }]]• [ Messi, [{ Ronaldo, tag, Messi, Post }]]• [ Post, [{ Ronaldo, tag, Messi, Post }]]

2. NFS: STORAGE

• Store Connections

• Model• [from, to, weight]

from to weight

A B 0.1

A C 0.2

C A 0.3

2. NFS: AGGREGATION

• News feed Plans• Pull: generate feed item for requested user as soon as he|she request

• Push: generate feed item for connected users as soon as a user action

• Pull & Push• Active user push

• Other pull

• Schedule: generate feed item for connected user

2. NFS: AGGREGATION

• Steps1. Iterate Activities

2. Select Connections

3. Generate Feed items

Focus Push plan

2. NFS: AGGREGATION

• Select connections• Activities: Ronaldo post Content on a Group

• Connections

owner subject verb object target

Ronaldo Ronaldo Post Content Group

Group Ronaldo Post Content Group

from to weight

Neymar Ronaldo 0.5

Kaka Ronaldo 0.5

Suarez Messi 0.8

Kaka Group 0.5

• Generate Feed items• Feed items

owner order SVO VOT Data

Neymar 1.1 RPC PCG {}

Kaka 1.2 RPC PCG {}

Kaka 1.5 RPC PCG {}

2. NFS: AGGREGATION

• Feed items

1.1

Feed item

0x0001

0x0002

1.2

Feed item

0x0001(RPC)

0x101(PCG)

1.5

Feed item

0x0001(RPC)

0x101(PCG)

2. NFS: DISPLAY

• Front-ends• Web: HTML, JSON, AJAX

• Mobile: HTML, JSON, XML

• API: JSON

2. NFS: DISPLAY

• Group• Example: Ronaldo and Messi commented on Content

• Get relation contents

• Generate HTML, JSON

1.2

Feed item

0x0011

0x101

1.5

Feed item

0x0001

0x101