Facebook Interview Question for Software Developers


Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
0
of 0 vote

I wish I can add the graphical diagram in the answer.

Anyway, I will do my best.
It is frustrating to put textual diagram here though. Sorry for the messy diagram.

|------------------|																	
  |	Client   A  | <-----------------     
  |------------------| 	    		 | query to connect live feeder
     	  |					 | 
	  |					 |					  |---------------|
	  |					 |					  |	Client B|
	  |					 |					  |---------------|
      	  | PUSH com                   |							|
	  |	(live feeds)    		V							|
	  |		      	  |--------------------------------|  				|	
	  |			  |	Live feed router 1..n |				|
	  |			  |--------------------------------|				|
	  |			  									|
	  |												|
	  |			  |--------------------------|					|  Status change
	  |-------------------|	Live feeder 1..n |  					|
				  |--------------------------|					|
					^								|
					| subscribe						|
					|								|
	|-----------------------------|								|											
    	| Message Bus      1..n|     							|	
    	|-----------------------------|								|
			|										V
			|   publish		     			   |----------------------------|																	
			------------------------------------------ | application layer      |     
						     			   |----------------------------|

The followings are description of the components depicted in the diagram.

- Client A, Client B : represents client browsers
- Live feed router : is responsible for telling client which live feeder it should connect to.
it also checks the load level of live feeders. There can be mutiple live feed routers.
- Live feeder: is responsible for keeping COMET style push notification connection with the clients. Certain number of connections will be assigned by routers and it subscribes the changes that currently connected clients are interested from the message bus. This is either stateful or stateless. In case of the later, the client should keep track of which live feed it has now. We can assign GUID for each live feed.

- Message bus: is the intermediate channel allowing the application layer to publish the status change and live feeder to subscribe for the change.
Tricky part will be how we can handle too many subscribers for the celebrities who has lots of followers.
I think this can handled in many ways. For the simplicity, I would assume we set up the multi-layer subscription for these users' status.

- Application layer is business logic handling the write/read from the clients. Additional job this application layer also does is to publish the user's status to the message bus upon the write/update requests.

Assumptions made in this design are as follows:
-We don't develop push notification framework (a.k.a Commet)
-We have highly salable storage(DB) available.

Given that assumption, Live feeder, message bus, and Live feed router can be linearly scalable.

- hankm2004 October 20, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

message service->channel service<->push service<->client
                               friendship service

channel service stores if a user is online in memory.
When a user visits facebook homepage, message services returns a push server address to user and tells channel services and the user is subscribed for push. User then connects to the push server by socket.
When a user closes facebook, socket is disconnected. Push service tells channel service to unsubscribe the user.
When a comment is posted, message service send the comment to channel service. Channel service gets the thread followers and forward the comments only to those online through push service.

Push servers are sharded by userid with consistent hash

- ly September 21, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

xcvxcv

- xcvxc August 29, 2020 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

z

- Anonymous March 05, 2021 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

good

- Anonymous March 05, 2021 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

good

- unknown March 05, 2021 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

good

- unknown March 05, 2021 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

search for: Software Engineering Best Practices: What are the best practices for building something like a News Feed? on Quora

- unknown September 30, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

search for Software Engineering Best Practices: What are the best practices for building something like a News Feed? on quora

- unknown September 30, 2015 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More