Design a Mutual Friends Count Cache for Profiles and Suggestions
Last updated: November 29, 2026
Quick Overview
Design how Meta serves mutual friend counts and a few sample mutual friends on profiles, friend requests, and People You May Know, where computing intersections of large friend lists on every view is too expensive.
Meta
November 29, 20260
0
0 solved
Design how Meta serves mutual friend counts and a few sample mutual friends on profiles, friend requests, and People You May Know, where computing intersections of large friend lists on every view is too expensive.
Mutual friends appear on many Facebook surfaces, and computing them means intersecting adjacency lists from the social graph store. The interviewer checks when to compute on read versus precompute, how to cache pairwise results that are mostly read once, and how to keep counts reasonably fresh after friendship changes.
What the Interviewer Expects
- Estimate the cost of intersecting two friend lists
- Decide between on-read computation with caching and precomputation
- Design cache keys for pairs and invalidation on friendship changes
- Respect privacy (hidden friend lists) in samples
- Treat counts as approximate where acceptable
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- How do you handle users with 5,000 friends viewing other users with 5,000 friends?
- Would you precompute for PYMK candidates?
- How fresh must the count be after a new friendship?
- How do privacy settings change what can be cached?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Functional: for a viewer V and a target T, return the count of mutual friends and up to 3 names to show (respecting privacy: only friends whose friend lists are visible to V or who are friends wit...
High-Level Design
Friend lists live in the social graph store (TAO-like), cached in memory. A mutual friends service computes on demand: fetch V's and T's friend id lists (sorted), intersect, filter, pick samples b...