News · New this week
LinkedIn 2nd-degree connections and cached 1st-degree lists
The standard system design answer is to compare two cached 1st-degree lists, not to walk the connection graph on every profile view.
You open a recruiter's profile and the 2nd badge is already there. The obvious guess is that the system searched your whole network to find the link. It didn't, and in a system design interview that answer gets rejected fast.
One caveat first. This is the standard interview design, not LinkedIn's own internal system. It's the answer to give, and it explains the behavior well.
Why walking the graph fails
The first idea most people reach for is to walk the entire connection graph every time someone views a profile. On every profile view, that is way too slow.
So the design has to avoid searching live. The work needs to be done before anyone opens the profile.
The degrees, quickly
A direct connection is your 1st degree. Someone connected to that person, but not directly connected to you, is your 2nd degree.
That definition is the whole trick. To know whether someone is 2nd degree, you only need to know who your direct connections are and who theirs are. You don't need the rest of the graph.
Cached 1st-degree lists
Every user's 1st-degree list is already saved, and kept in a cache. A cache is a copy kept close, so it's ready instantly. There's no search across the network at request time, just two lists that are already on hand.
When you view the recruiter's profile, the server compares your list with the recruiter's list. If there's one common name, and the recruiter isn't directly connected to you, that's a 2nd-degree connection. The badge shows up.
The twist is that a full graph is never searched live. The comparison touches two lists and nothing else.
People You May Know
People You May Know is a different kind of problem. Instead of a yes or no answer, people get ranked.
The signals are how many mutual connections you share, whether you work at the same company, and whether you went to the same college.
What to say in the interview
If you get this question, keep the answer short. Don't walk the graph, compare the cached list.
That's the line to remember. When someone asks how the 2nd badge appears so fast, the answer is two saved lists and one common name.



