Design a Social Graph Store for Friend and Follow Edges
Last updated: November 29, 2026
Quick Overview
Design a storage and caching layer that holds billions of users and the friend, follow, and block relationships between them, serving very high read rates for queries like 'list my friends' and 'are A and B friends'.
Meta
November 29, 20260
0
0 solved
Design a storage and caching layer that holds billions of users and the friend, follow, and block relationships between them, serving very high read rates for queries like 'list my friends' and 'are A and B friends'.
Meta built TAO for exactly this problem, so senior candidates are often asked to reason about a read-dominated graph store. The interviewer checks the object and association data model, how you keep a cache consistent across regions, and how you handle very high-degree nodes.
What the Interviewer Expects
- Model data as objects and typed associations with inverse edges
- Design for a read to write ratio around 500:1 with a cache tier in front of sharded storage
- Explain cache consistency for writes and cross-region replication
- Handle supernodes with millions of edges
- Define the query API (get assoc, count, range by time)
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 keep A-friends-B and B-friends-A in sync when they live on different shards?
- How would you answer mutual friend counts efficiently?
- What consistency guarantees do you give a user who just accepted a friend request?
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: create and delete edges of types (friend, follows, blocks), list edges of a type ordered by time, count edges, check membership. Non-functional: reads p99 < 10 ms from cache, extre...
High-Level Design
- API:
assoc_add(id1, type, id2, time, data),assoc_delete,assoc_range(id1, type, offset, limit),assoc_count(id1, type),assoc_get(id1, type, id2_set). - Storage: sharded MySQL-lik...