Design a People-You-May-Know Friend Recommendation System
Company: Meta
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Onsite
Design a friend recommendation feature ("people you may know") for a large social network. Each user sees a list of people they are not yet connected to but are likely to know and want to add. From the list, a user can send a friend request or dismiss a suggestion.
```hint Most candidates are nearby
Think about where in the social graph the people a user knows but has not added yet are most likely to be.
```
```hint Separate finding from ordering
Scoring every user on the network for every viewer is impossible; decide what produces a manageable candidate set before any ranking happens.
```
### Clarifying Questions
- How many users are there, and what are the average and maximum friend counts?
- Is the relationship mutual (friends) or one-directional (follows)?
- Which signals may be used: mutual friends, shared schools or workplaces, uploaded contacts, location? What privacy constraints apply to each?
- How soon after a user adds a new friend should recommendations reflect it?
- What is the success metric: requests sent, requests accepted, or longer-term interaction between the new friends?
### What a Strong Answer Covers
- Candidate generation from graph proximity and other sources
- Offline batch computation versus online updates, and freshness after graph changes
- A ranking model with a well-chosen label and features
- The serving path, precomputed storage, and read-time filtering
- Filtering of existing friends, pending requests, blocks, dismissed suggestions, and privacy settings
- Handling of very high-degree users and brand-new users
- Offline and online evaluation, and the feedback loop from user actions
### Follow-up Questions
- How do you compute friends-of-friends for a user whose friends themselves have very large friend counts without an explosion of work?
- A brand-new user has no friends yet. What do you show?
- How do you avoid recommendations that reveal information the candidate or the viewer would not expect to be shared?
- How would you evaluate a new ranking model offline and then online?
Overview: A system design question on recommending people a user may know on a large social network, from candidate generation through ranking and serving. It tests graph-based candidate sourcing, batch versus real-time freshness, ranking signals and labels, filtering, privacy, cold start, and evaluation.