Phase 1 — Clarify & Scope
Interviewer: Design a social graph system — think Facebook's friend graph or Twitter's follow graph. What do you want to clarify?
Candidate: Important distinctions:
- Undirected (mutual friendship like Facebook) or directed (follow like Twitter/Instagram)?
- What operations dominate — reads (show my friends), writes (add friend), or graph traversals (friends of friends, mutual friends)?
- What's the scale — users and connections?
- Do we need to support graph queries like shortest path, or just direct queries (is A friends with B, list A's friends)?
- Real-time features — follower counts, activity feed based on social graph?
Interviewer: Both: directed follow graph (Twitter-style) AND undirected friendship (Facebook-style). Focus on the data model and query patterns. 1 billion users, average 500 connections per user. Support: add/remove connections, list followers/following, check if two users are connected, compute mutual friends. No shortest path needed. Follower counts should be real-time.
Candidate: Let me size this:
At 16 bytes per (user_id, user_id) pair (8 bytes per BIGINT):
Reads dominate: every timeline render, every profile visit checks the social graph.
In the full tutorial
- Phase 2 — High-Level Architecture
- Phase 3 — Deep Dive & Evolution
- Phase 4 — Robustness & Operations