Facebook Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: In-Person
OH MY GOOOD that the question?((
my Answer
1. module Core
2. widget Functions of material (like, comments, share, delete for item, all functions for item in one widget)
3. view File, like method
4. controller File, get like method from model subject
5. itemSubject(current material, example Photo User or Wall Action etc.)
6. in modelDbTablesLikes, getLikePaginator
7. in database in table "core_likes" like_id resource_type resource_id poster_type poster_id
I answered correctly? :(
Scenario: like, undo like
Service: post service, like service
When a post is liked, count+1 and store the action.
When a like is undone, count-1 and remove the action.
Storage:
count table
likes count needs to be loaded when loading timeline, so use user_id as consistent hash key so that it is on the same machine as the user's timeline.
no sql row key user_id, column key post_id, value likes
like table
no sql db
row key post_id
column key timestamp+ user_id1, user_id2, ...
value user name
Scale:
read qps = dau 1b x 10 read per day/86400 = 100k
peak = 200k, growth = 400k
like qps = 1b x 1/86400 = 10k
peak = 20k, growth = 40k
cache both tables
1b user_id = 4g
reference
ebaytechblog.com/2012/07/16/cassandra-data-modeling-best-practices-part-1/ 2
I would say that the Like button is a way to create an edge in the OpenGraph between the user and the liked entity. So in my opinion the question is more like: Design a way to represent such a huge graph with different type of edges (likes, friendships, etc...)
- Claudio October 05, 2012