LinkedIn

Professional Network

Design a professional network: profiles, two-way connections with 1st, 2nd and 3rd-degree badges, a feed, people you may know, and job search.

Overview

A professional network looks like other social apps, but its core is a two-way connection graph. When two members connect, each becomes a 1st-degree connection of the other; their connections become each other's 2nd degree; one more hop is 3rd degree. The app shows that degree next to nearly every name, lists mutual connections, and uses the graph to decide which posts, people and jobs to show.

So the interview has two halves. The first is the graph: storing tens of billions of edges and answering 'how is this person connected to me?' in milliseconds, hundreds of thousands of times a second. The second is ranking: a feed, People You May Know and job recommendations all pick a few items from millions, using the graph as one of their strongest signals.

LinkedIn has published a lot about its own systems (Kafka started there, and it has written about its graph database, its feed and its recommenders), so this page can name what LinkedIn actually built, with sources.

Questions to ask first

  • How many members and how active? — About 1 billion members; 150 million active a day
  • How connected? — 200 connections on average, a long tail into the tens of thousands
  • Which degrees are shown? — 1st, 2nd, 3rd, and 'out of network' beyond that
  • Which features go deep? — The graph and degree badges first; then the feed, People You May Know and jobs
  • How fresh? — A new connection shows up at once; recommendations may lag by minutes
  • Privacy? — Members can hide their connections list; blocking removes all visibility

What you will be able to do

  • Store a two-way graph and compute degree badges and mutual connections by intersecting sorted lists.
  • Explain why graph serving is in memory and how LinkedIn's LIquid changed People You May Know.
  • Design a feed that pulls from followed members' timelines at read time, as LinkedIn's FollowFeed does.
  • Walk through multi-stage ranking for People You May Know and for jobs.
  • Show how Kafka turns writes into the derived data that every one of these features reads.

Key concepts

  • Two-way edges
  • Adjacency lists
  • Degree badges
  • Sorted-list intersection
  • Graph serving
  • Fan-out on read
  • Multi-stage ranking
  • Embedding retrieval
  • Kafka activity events
  • Derived data

Functional requirements

  • Create and edit a profile (headline, experience, education, skills)
  • Send, accept, ignore and withdraw connection requests; remove a connection
  • Show the viewer's degree (1st, 2nd, 3rd) and mutual connections next to any member
  • A home feed of posts and activity from connections and followed members and companies
  • People You May Know suggestions
  • Search and recommend jobs; apply

Non-functional requirements

  • A degree badge in under about 10 ms, because a page shows dozens of them (a target we chose)
  • Feed p99 under about 200 ms (a target we chose; LinkedIn reported about 140 ms p99 for FollowFeed in 2016)
  • A new connection is visible to both members at once; derived features may lag by minutes
  • Graph reads stay available when the source-of-truth store is degraded (serve from replicas)
  • Privacy settings and blocks are enforced on every read path

Interview questions

  • How do you show 1st, 2nd or 3rd degree next to every name on a page?
  • Why not precompute everyone's 2nd-degree network?
  • How is the feed built?
  • How does People You May Know work?
  • How do you make a new job findable within seconds?
  • Where does Kafka fit, and why did LinkedIn build it?
  • What happens when someone accepts an invitation?

Sign up free to read the full topic

More System Design topics

Start free on Cariara · Coding problems · System design studio