System design interview: how to design a feeds system (e.g., Twitter, Instagram and Facebook news feed)

System design interview: how to design a chat system (e.g., Messenger, WeChat or WhatsApp)

Methodology: READ MF!

Please use this "READ MF!" framework for software engineer system interview purpose.

Key designs and terms

  • So far the best detailed explanation on designing twitter is from Raffi (used to be VP of Twitter) on QCon. Presentation, Slides [All credits go to QCon). Raffi is very smart and articulate, really solid guy!
  • Read heavy system, not write heavy, optimized for user timeline. To be clear, there are two timelines, one is user‘s own tweets (easy to do), the other is the main timeline which is an aggregation of all the tweets from the people that user follows.
  • Pre-calculate all the timelines. This is the interesting part of the design vs using a mysql and having index to query in realtime, which would not be scalable. When a tweet is posted, the tweets service would
    • Store this tweet in memory, and that later would be flushed to a main DB
    • Call the fanout deliver service to publish this tweet to all the users‘ timeline that followed this particular user. It could simply store a tweet ID (and later the content could be retrieved from the Tweets Cache) or hydrating the entire text content is also fine (note how we want to handle eidt or delete, twitter probably doesn‘t allow delete)
    • Call search service to index (Lucene). The search index is also hosted in memory on Redis. Note search here needs to fanout to all search clusters but due to the inmemory hosting, it‘s acceptable.
  • Always remember disk access is at least 100x slower than memory access, e.g, disk is 10ms vs 100ns on memory. https://gist.github.com/jboner/2841832
  • With the pre-caculate timeline design, there might be race conditions when celebrity (people with millions of followers) starts to talking to each other with replies. E.g., celebrity A tweets something, takes 30 sec to deliver to all the followers,  celebrity B replies before deliver finishes, some followers follow both A and B might see B‘s reply first before A‘s original post. One cheat workaround is to sort by timestamp or tweet IDs, but they are also experimenting with only pre-calculate non-celebrity tweets, and when generating timeline, realtime fetching the celebrity tweets. It depends which way is better and also the user experience. This is a good stop point to talk to your interviewers in real world about tradeoffs.
  • Since twitter is heavily relying on cache, you might want to checkout how they optimized the caching with twemproxy.

Baozi Youtube Video

原文地址:https://www.cnblogs.com/baozitraining/p/12110690.html

时间: 2024-07-31 22:23:31

System design interview: how to design a feeds system (e.g., Twitter, Instagram and Facebook news feed)的相关文章

System design interview: how to design comments and reply, likes button and total views on Youtube

System design interview: how to design comments and reply, likes button and total views on Youtube Methodology: READ MF! [Originally from the Post: System design interview: how to design a chat system (e.g., Facebook Messenger, WeChat or WhatsApp)] R

Material Design with the Android Design Support Library

Material Design with the Android Design Support Library 原文http://www.sitepoint.com/material-design-android-design-support-library/ Material Design,Android 5.0发布时为android app 和其他平台app引入的一门新的设计语言. 它带来了一些新的UI组件,如“Floating Action Button”.实施这些新组件,同时确保向后兼容

問題排查:System.BadImageFormatException: 未能加载文件或程序集“System.ServiceModel

錯誤訊息如下: System.BadImageFormatException: 未能加载文件或程序集“System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”或它的某一个依赖项.该模块应包含一个程序集清单. 文件名:“System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934

对于System.Net.Http的学习(一)——System.Net.Http 简介(转)

最新在学习System.Net.Http的知识,看到有篇文章写的十分详细,就想转过来,自己记录下.原地址是http://www.cnblogs.com/chillsrc/p/3439215.html?utm_source=tuicool&utm_medium=referral System.Net.Http 是微软推出的最新的 HTTP 应用程序的编程接口, 微软称之为“现代化的 HTTP 编程接口”, 主要提供如下内容: 1. 用户通过 HTTP 使用现代化的 Web Service 的客户端

[转]ADT中通过DDMS导入文件出错ddms transfer error: Read-only file system,Failed to push selection: Read-only file system

[已解决] 原文  http://www.crifan.com/ddms_import_file_error_transfer_error_read_only_file_system/ 想要通过adt的ddms的file explorer去向adv中导入文件,结果出错: [2013-04-23 10:32:00 - ddms] transfer error: Read-only file system [2013-04-23 10:32:00] Failed to push selection:

Windows System Account、Linux System Account SSH Weak Password Detection Automatic By System API

catalog 0. 引言 1. windows系统账户弱密码检测 2. windows弱密码检测遇到的问题 3. linux系统账户弱密码检测 0. 引言 windows.linux密码暴力破解.身份认证.密码策略加固的相关知识,请参阅另外两篇文章 http://www.cnblogs.com/LittleHann/p/3662161.html http://www.cnblogs.com/LittleHann/p/4515498.html 今天我们来讨论一下如何在客户端通过系统API实现弱密

Java获取系统环境变量(System Environment Variable)和系统属性(System Properties)以及启动http://m.jb51.net/article/83454.htm参数的方法

系统环境变量(System Environment Variable): 在Linux下使用export $ENV=123指定的值.获取的方式如下: Map<String,String> map = System.getenv(); Set<Map.Entry<String,String>> entries = map.entrySet(); for (Map.Entry<String, String> entry : entries) { System.o

对于System.Net.Http的学习(一)——System.Net.Http 简介

http://www.cnblogs.com/chillsrc/p/3439215.html System.Net.Http 是微软推出的最新的 HTTP 应用程序的编程接口, 微软称之为“现代化的 HTTP 编程接口”, 主要提供如下内容: 1. 用户通过 HTTP 使用现代化的 Web Service 的客户端组件: 2. 能够同时在客户端与服务端同时使用的 HTTP 组件(比如处理 HTTP 标头和消息), 为客户端和服务端提供一致的编程模型. 命名空间 System.Net.Http 以

Linux System Account SSH Weak Password Detection Automatic By System API

catalog 1. Linux弱口令攻击向量 2. Linux登录验证步骤 3. PAM 4. 弱口令风险基线检查 1. Linux弱口令攻击向量 0x1: SSH密码暴力破解 hydra -l root -P /root/passwdCracker/password.lst -t 16 -vV -e ns 112.124.51.10 ssh 对于Linux系统来说,从外部破解系统密码的途径只有SSH这一条路,攻击者必须借助网络进行密码猜解尝试 0x2: Linux SSH空口令帐号 1. 通