Important things

302 http response with Location header for url redirection(GET and Head) - 307 for temporary redirection ,==> Spring Sleuth - tracing in microservices, ==> https://astikanand.github.io/techblogs/high-level-system-design/design-bookmyshow, https://www.hellointerview.com/learn/system-design/in-a-hurry/introduction

Saturday, 29 May 2021

Prepare for Facebook System Design Interview [Pirate Round]

What is the System Design Interview Round at Facebook?

image

  1. System Design Interview Round is also known as the Pirate Interview round at Facebook.
  2. In this round, you will be asked to show off your design skills. The system design questions asked are typically more open-ended and feel more like a discussion.
  3. The design interview is 45 minutes long. It rarely involves coding. You will spend most of the time talking and drawing on the whiteboard.
  4. The purpose of the interview is to assess the candidate's ability to solve a non-trivial engineering design problem. The interviewer will ask you a very broad design problem and evaluate your solution.

Now let us review the top system design questions which are usually asked at Facebook.




Question 1: Design Facebook News Feed

image

In the Design Facebook News Feed question, design the following key features and their APIs.

  1. Facebook users should see the news feed containing posts and statuses from their friends and pages that they have followed.
  2. They can post and like statuses that may contain text, images, and videos.
  3. They can send friend requests to other users and follow other pages.

Design Goals

  1. Minimum latency
  2. High Availability
  3. Eventual Consistency (Due to CAP Theorem)
  4. Read-Heavy Service

Scale Estimations

  1. One billion daily active users (DAUs)
  2. Ten billion news feed requests daily
  3. On average:
    • Each user posts twice a day
    • Each post is liked five times
    • Each user has 200 friends
    • Each user follows 100 pages




Question 2: Design Facebook Status Search

image

Facebook provides a search bar at the top of its page to enable its users to search posts, statuses, videos, and other forms of content posted by their friends and the pages they follow. In this question,

  1. Develop a service to enable the users to search the statuses posted on Facebook by their friends and followed pages.
  2. Consider that these statuses will only contain text for this particular question.

Design Goals

  1. We should ensure that the final system has minimum latency, and users should not experience any significant lag while searching for the statuses.
  2. The system should be highly available.
  3. Due to the CAP theorem, we will aim for an eventually consistent system.
  4. Our system will be read-heavy as more users will be searching on Facebook rather than posting statuses. Thus, the number of read requests will be far greater than write requests.

Scale Estimations

For an efficient system, we will have to consider the following scale estimations.

  1. On average, the system will have one billion daily active users
  2. Receive around five billion search requests daily
  3. About one billion statuses will be generated by the users per day.




Question 3: Design Live Commenting

image

This question is not related to Live Videos. This question is related to the active real-time feed of comments at the bottom of each post. Thus, in this question,

  1. Design the backend of a system that can enable real-time commenting on Facebook posts.
  2. The users should be able to see the new comments in real-time for the posts visible in front of their screen.

This problem is quite challenging, as users are continuously scrolling the news feed, and thus the posts that are visible in their view can change very frequently.

Scale Estimations

To design an efficient system in the interview, we will have to consider the following scale estimations. These estimations will help us in explaining the scale of the system to the interviewer.

  1. Every minute, Facebook serves over 100 million pieces of content that may receive comments.
  2. In that same minute, users submit around a million comments that need to get routed to the correct viewers.




Question 4: Design Facebook Messenger or WhatsApp

image

Develop the backend of a messenger system that can,

  1. Support 1:1 conversations between two users.
  2. Track the online or offline status of the users.

If time remains, discuss more complex features like Group conversations and Push notifications.




Question 5: Design Instagram

image

Design a simpler version of Instagram.

  1. Users can upload and share photos.
  2. They can follow other users.
  3. Like the photos posted on Instagram.
  4. Instagram users should get a scrollable feed of photos that are posted by the users they follow.




Question 6: Design Typeahead Suggestions

image

Google predicts and suggests a list of autocomplete queries based on the characters that we have already typed in the search box.

  1. Suggest the top ten search queries based on the characters already typed by the user in the search box.
  2. Assume query's popularity can be determined by the frequency of the query being searched in the past.




Question 7: Design Privacy Settings at Facebook

image

We can set different privacy levels for the Facebook posts we publish to be only visible to a specific set of users like public, friends, friends of friends, etc.

  1. Enable a user to specify the different levels of privacy for a post so that it is only visible to a particular set of users.
  2. Implement two levels of privacy, Public and Friends.
  3. Optional Complex Levels: friends of friends, custom groups




Question 8: Design Proximity Server

image

Proximity servers are used to discover nearby attractions such as places and events, which are then recommended to Facebook users.

  1. Users can add, update, and delete places.
  2. Given a location expressed as latitude and longitude, users can query all the nearby places within a given distance.
  3. Optional Follow-up: Query events near a given place around a particular time. This adds the third dimension of time to the problem.




Question 9: Design Top N Songs

image

This question is very similar to designing the system for Top N Trending topics.

  1. Get the top N songs for a user over the past X days.
  2. Assume popularity of a song can be determined by the frequency of the song being listened to in the past.




Question 10: Design Web Crawler

image

Web Crawler scans the world wide web to download and index all the web pages to be made available for the search queries submitted by the users.

  1. Given a list of seed web pages, it should download all the web pages and index them for future retrieval.
  2. The service should handle duplicate web pages so that unique URLs are stored.

Design Goals

  1. We should ensure that our service is highly scalable, as it needs to crawl the entire Web and fetch billions of web pages.
  2. It should implement the Robot Exclusion protocol, allowing web admins to declare parts of their websites off-limits to crawlers.
  3. For the simplicity of the interview, we can consider that we will crawl only HTML pages.

Scale Estimations

  1. Our System will be crawling about 25 billion web pages every two weeks.
  2. On average, each URL will be 512 bytes in size,
  3. And each page will be about 100 KB in size.

No comments:

Post a Comment