# Design a social graph service: system design interview question

> Frequent relationship changes, users with many connections, and graph queries with strict cost and freshness limits.

Source: https://sysround.com/questions/design-social-graph-service
Updated: 2026-11-05


Difficulty: hard. Levels: Senior, Staff+.

## How the interviewer opens it

"Design a service that stores user relationships and answers mutual-connection and neighborhood queries. Support users with many connections and frequent relationship changes."

## What to clarify first

- Relationship meaning
- Query limits
- Graph size
- Traffic and read:write mix
- Latency
- Consistency and availability
- Pages and concurrent changes
- Mutation retries
- Durability and retention
- Scope exclusions

## Scope of a strong answer

Core requirements:

- Create, delete, and check a directed follow relationship.
- Return pages of followers and followees.
- Return common followees for two users.
- Return a sample of users reached through two directed edges.

Usually out of scope:

- Friend requests and approvals.
- Feed generation and recommendation rank.
- Private accounts and block rules.
- Queries beyond two edges.

## What interviewers probe

### Relationship changes

Each relationship supports two query directions. Retries and delayed updates can conflict with later changes.

### Users with many connections

Large lists increase page and query costs. Popular users also concentrate reads and relationship changes.

### Mutual connections

The service compares lists with very different sizes. Frequent changes make permanent results for every user pair expensive.

### Neighborhood query cost

A small result can require a huge search. Duplicate paths and large intermediate lists make result limits poor cost limits.

## Common mistakes

- The design stores each user's connections in one unlimited record.
- The design treats both edge directions as independent facts without repair.
- The candidate assumes durable writes make every replica read current.
- The design repeats an old mutation after a later opposite change.
- The design limits result size but ignores the number of examined edges.
- The candidate promises complete graph results within fixed latency for every user degree.

## The bar by level

- **Senior:** The candidate splits large lists and maintains reverse updates through failures. The design implements edge-scoped retries and linearizable edge checks. The candidate bounds query work and explains page and freshness limits.
- **Staff+:** The candidate quantifies worst-case query costs and reserves capacity by request class. The design preserves mutation history and cursor progress during partition movement. The candidate defines projection repair and safe delete retention.

Practice this question with an AI interviewer: https://sysround.com/practice/new?problem=social-graph


---
SysRound (https://sysround.com) is an AI practice tool for system design interviews. It has a voice or typed AI interviewer and a shared whiteboard. At the end, you get feedback on each skill and a model answer. The AI feedback can be wrong.
