Facebook Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: In-Person
ALGO
-------------
User table
=========
1. Each user has a unique ID which. (we have to generate a random ID)
2. Once user logs in that ID associates with user all time
Message Table
=============
1. Each message has a unique ID (we have to generate random no + UserID from User table)
There are multiple steps in designing this. format for storing user info is the last thing. First we need to think about data storage. Think about Availability, concsistency, replication, tolerance. For gmail like system, it should be strongly consistent. It should be available and hence it needs to be replicated both within the datacenter as well as across datacenter. BigTable/HBASE like system will work for this. Next level is to support a webservice which can interact with webclient as well as mobile client. This should support any mail format like IMAP/POp3. A load balancer need to be installed at the front to receive connections. when a user sends a mail, the webservice needs to call the appropriate storage service to store the mail contents to the sent users. It needs to call the notification service to notify the users. This requires that the webclient keep a persistent TCP connection. The server will push the notification on this connection. For mobile clients the notification service should push the message to mobile push service. This mobile push service needs to handle the case of pushing the notification through carrier. This is the basics. Then we can talk about more features like seraching the older mails, filters, settings etc.
- Anonymous January 26, 2013