Facebook Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: In-Person
Scenario: user posts status, user receives news feed from friends
Service: news feed, friendship
When user posts status, write to db.
When user requests news feed, get the top 100 status from each friends, merge and return top 100
Storage:
status nosql row key user id, column key time stamp, value status
friend nosql row key user id, column key tie stamp, value friend id
disk = 1b dau * 0.5 post/day * 100byte = 50G/day
Scale
read qps = 1b * 5 read per day /86400 = 100k
peak = 200k, growth = 400k
write qps = 1b * 0.5/86400 = 10k
peak = 20k, growth = 40k
Turn on caching since qps is high.
memory = 1b*100*100byte = 10T.
So we need at least 100 100GB ram database server
This is a good explanation, also is linked to a video where a facebook Engineer briefly explains how the newsfeed works in stack overflow: what-is-the-design-architecture-behind-facebooks-status-update-mechanism
- mina October 11, 2012Observer Pattern is very heavy for facebook since they have so many users. According to the video they cache the latest status updates for every user in their memcache server, and everytime a user wants to look at their news feed it hits those servers and get the top stories (+ more details)