News feed
1. Level 1.0
Database Schema:
a. User
| UserID | Name | Age |
| 1 | Jason | 25 |
| 2 | Michael | 26 |
b. Friendship
| FriendshipID | SourceID | TargetID |
| 1 | 1 | 2 |
| 2 | 2 | 1 |
c. News
| NewsID | AuthorID | Content | Timestamp |
| 1 | 2 | "Hello" | 2015-01-10 |
| 2 | 1 | "Hi" | 2015-01-10 |
Why bad?
100+ friends
a. 1 query --> get friends list
b. 1 query -->
SELECT * FROM news
WHERE timestamp > xxx
AND authorID IN frientsList
LIMIT 1000
IN is slow
2. Level 2.0
a. Pull: Get news from each friend, merge them together. NewsFeed generated when user request.
b. Push: NewsFeed generated when news generated. We have anthor table to store newsfeed, may cause duplicate news.
Push: disadvantage: News Delay.
3. Level 3.0
a. Popular star(Justin Bieber)
Flowers 13M +
Async Push may cause over 30 minutes (13M+ insertions, delay too long)
b. Push + Push
for popular star, don't push news
for every newsfeed request, merge non-popular users newsfeed(push) and popular users newsfeed(pull).
4. Level 4.0
Push disadvantage:
a. Realtime
b. Storage (Duplicate)
c. Edit
Go back to Pull:
a. cache users' latest(14 days) news
b. Broadcast multiple request to multiple server (shard by userID)
c. Merge & sort newsfeed(time, forward frequency, friends' forward, dedup, sort)
d. Cache newsfeeds for this user with timestamp (user_login)
News feed的更多相关文章
- 问题--feed列表有新闻重复的问题
1. 经常有运营反应,客户端展示的feed列表有重复的问题. 重复问题分为两种,一种是两条新闻标题类似,另一种是两条新闻标题是完全相同. (1)标题类似 原来过滤的逻辑,是两个标题完全相等,才认为两条 ...
- 读取微博feed伪代码
// 读取我的好友fids $db = new DB(); $mc = new Memcached(); $_uid = 1; // my uid $sql = "select * from ...
- poj 2761 Feed the dogs (treap树)
/************************************************************* 题目: Feed the dogs(poj 2761) 链接: http: ...
- [UWP]涨姿势UWP源码——RSS feed的获取和解析
本篇开始具体分析涨姿势UWP这个APP的代码,首先从数据的源头着手,即RSS feed的获取和解析,相关的类为RssReader,所有和数据相关的操作均放在里面. 涨姿势网站提供的RSS feed地址 ...
- 如何禁用wordpress的RSS Feed
RSS(Really Simple Syndication)是一种描述和同步网站内容的格式,早期使用RSS订阅能更快地获取信息,网站提供RSS输出,有利于让用户获取网站内容的最新更新.但随着采集技术的 ...
- ACM BUYING FEED
BUYING FEED 时间限制:3000 ms | 内存限制:65535 KB 难度:4 描述 Farmer John needs to travel to town to pick up ...
- NuGet v3 feed带来的惊喜
估计有1个月了,在mac上编译dnx从来没有成功过,因为在安装nuget packages时连接myget.org总是超时. 今天在 ASP.NET 5 Beta5 Now Available 中得知 ...
- php + Redis 写的类似于新浪微博的feed系统
最近接了一个feed系统的外包,类似于微博那种!客户端是ios和android,服务器用的php,数据库用的是redis.分享下服务器和数据库部分的功能!希望对大家有帮助. 关于redis的介绍,大家 ...
- 划分树---Feed the dogs
POJ 2761 Description Wind loves pretty dogs very much, and she has n pet dogs. So Jiajia has to fee ...
- 微博feed系统的推(push)模式和拉(pull)模式和时间分区拉模式架构探讨
sns系统,微博系统都应用到了feed(每条微博或者sns里的新鲜事等我们称作feed)系统,不管是twitter.com或者国内的新浪微博,人人网等,在各种技术社区,技术大会上都在分享自己的feed ...
随机推荐
- 九度OnlineJudge之1021:统计字符
题目描述: 统计一个给定字符串中指定的字符出现的次数. 输入: 测试输入包含若干测试用例,每个测试用例包含2行,第1行为一个长度不超过5的字符串,第2行为一个长度不超过80的字符串.注 ...
- NOI2014 Day2
NOI2014 Day2 动物园 题目描述:给出一个字符串(长度为\(Len\)),设\(num[i]\)为字符串的前\(i\)个字符构成的子串(\(A\))中,满足\(A\)的前\(L\)个字符既是 ...
- [LeetCode][Python]15:3Sum
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 15: 3Sumhttps://oj.leetcode.com/problem ...
- [虚拟化/云] kvm的架构分析
预备知识 1. 客户机物理页框到宿主机虚拟地址转换 http://blog.csdn.net/zhuriyuxiao/article/details/8968781 http://www.tuicoo ...
- 美国TJX公司 - MBA智库百科
美国TJX公司 - MBA智库百科 TJX公司总部设在美国波士顿,在北美地区和许多欧洲国家开有连锁分店,仅在美国就有2500多家分店. TJX Companies, Inc. 是美国和全世界的服装和家 ...
- C++与AS3
ActionScript 3(简称AS3)与 c++ 都是面向对象的编程(OOP)语言,都具有OOP的特性如封装.继承.多态等.二者在语法上有许多相似之处,基本上学过C++之后再学习AS3感觉并不是特 ...
- js 使用for循环遍历数组
今天写个无聊的东西!for循环的使用! 例如以下:定义a数组,b为伪数组! var a = [1,2,3,0,5,4]; var b = document.getElementsByTagName(' ...
- Android_按钮被按下效果的实现(selector选择器)
在很多刚入门的新手在开发实例的过程中,经常会遇到要按下某个ImageView时,需要加入确认感的时候.需要在按下的时候,控制ImageVIew内图片的显示. 在我是新手的时候,也这样做过.所以这里简单 ...
- HTML之学习笔记(八)表格
Html的表格使用table标签.table标签含有tr(table row)子标签,tr又含有th(table head)和td(table data)子标签这样的嵌套结构 代码演示 <tab ...
- 12 款最好的 Bootstrap 设计工具
作为一位设计师,会经常追寻新鲜有趣的设计工具,这些工具会提高工作的效率,使得工作更有效, 最重要的是使工作变得更方便.非常肯定的说,随着日益增长的工具和应用的数量,设计和开发变得越来越简单了. 其中最 ...