LinkedIn Connection Graph 00:00:01 Connect two people without exposing private edges Asha sends a professional connection request. Design a LinkedIn-style graph where invitations, accepted connections and blocks are different states. Pressing Connect twice should not create two independent relationships. The app sends the target, an optional message and an idempotency key. a retry on a bad connection must not create a second invitation. Evaluate blocking and privacy policy before sending the invitation. The external result should preserve the chosen privacy semantics. Change data capture publishes it to Kafka. new readers can be added without changing the service. Each shard inserts one number in order. Applying the same event twice changes nothing. the log may deliver again. Commit a relationship change durably and update both adjacency views through a repairable process. Avoid exposing a private relationship indirectly in counts, error messages or search results. 00:01:01 Why a second-degree badge costs more than it looks Two members can be direct neighbors, share a visible neighbor or be more distant. A profile page asks for a bounded degree badge rather than the entire social graph. The app asks for the degree of the target. the badge is part of the first screen. 800 numbers, not 250,000. comparing beats walking. Had the overlap been empty, the shards would test the friends of the shorter side. stop at the first answer. "2nd, 15 mutual connections". An unavailable or skipped deeper search is an unknown result. Distinguish that from proof of no connection, both in the API and in the interface. 00:01:42 Search from the smaller frontier To find a short connection path, start from both members and expand the smaller eligible frontier. Keep visited sets and depth information separately for each side. A and Z. How far apart? Both have one person, so A goes first. Z's side has one person, A's has three. E and F are one hop from Z. The two explored frontiers meet on a path of three edges in this worked graph. The answer identifies degrees of separation, not a count of people in the database. For a shortest path, expand layers and stop only when the algorithm's bound makes the candidate distance final. Access rules apply to intermediate edges as well as the endpoints. 00:02:26 A recommendation needs a permissible explanation People-you-may-know candidates may use visible mutual connections along with other eligible signals. A good ranking score cannot authorize disclosing somebody's private contact or blocked relationship. The nightly run, or a fresh accept. no member should wait for this work. Pair features and profile features, in batches. one call per candidate would be far too slow. At most two per company, several industries and seniorities. five colleagues in a row is dull. Each with a reason that is true, such as "12 mutual connections". Validate candidate generation, eligibility and the explanation independently. It can be appropriate to suggest a member while withholding details about how that candidate entered the set. 00:03:12 One unusually popular member changes the algorithm Two adjacency lists can differ by orders of magnitude. Copying or sampling the huge list for every profile view makes a simple intersection expensive or approximate. 500 against 30,000. With one mutual friend, a sample of 1,000 finds it 1 time in 30. 500 binary searches of about 15 steps each: 7,500 steps. Only a supernode's own list pages are costly: their set is kept an hour. Iterate the smaller list and check membership in the larger efficient representation. That keeps an exact mutual-neighbor question exact, while bounding the work by the smaller candidate set.