🎓 A1Learner
🔍
0 of 64 lessons completed

Design Tinder

Tinder shows one person a stack of profiles, one at a time, to accept or pass. A mutual match means both people accepted each other, and only a mutual match opens contact.

The ask

The service shows profiles one at a time. The viewer accepts a profile or passes on it.

A pass is silent. The profile owner never learns about a pass.

An accept is stored, not announced. It matters only if the other person also accepts.

Messaging starts only after a mutual match. The chat itself belongs to the chat system, and the match hands over two user IDs.

Estimate the scale

The service holds 100,000,000 users.

Swipes reach 1,000,000,000 a day.

1,000,000,000 swipes / 86,400 seconds = about 11,574 swipes per second.

The match rate is 1%.

1,000,000,000 swipes x 1% = 10,000,000 matches a day.

10,000,000 matches / 86,400 seconds = about 116 matches per second.

API and data

A profile record holds a user ID, photos and a short text about the person.

A settings record holds the wanted distance and the viewer's other filters.

The swipe operation takes the viewer ID, the profile ID and the verdict. The verdict is accept or pass.

The stack operation returns the next set of profiles for one viewer. Seen profiles never come back in that stack.

A match record holds the two user IDs and the time. One pair of users has at most one match record.

A report operation names a profile and a reason. Reports go to a review queue, not to the other person.

High-level design

Photos live in blob storage and serve through a CDN. Profiles are read far more often than they change.

A stack builder prepares profiles for each viewer. It applies the filters, then orders the stack.

A swipe service records verdicts. On an accept, it checks for a stored accept in the other direction.

A match service creates the match and notifies both people. Notifications go through the notification system.

How a stack is built

The stack starts with proximity search. Only profiles inside the viewer's stated distance enter the pool.

The viewer's settings cut the pool next. Each setting removes profiles the viewer does not want.

Seen, blocked and reported profiles leave the pool. A pass from either side also removes the pair.

The builder orders what is left and caches the stack. New swipes trim the cached stack instead of rebuilding it.

Distance comes from the phone's current area. A viewer who travels gets a stack for the new area on the next refresh.

Deep dive: the mutual match

A mutual match forms on the second accept. The first accept waits in storage as a standing yes.

The check and the create must act as one step. Two accepts landing together must still make exactly one match.

The match key is the pair of user IDs, in a fixed order. A retry of the same swipe finds the same key and stops.

Retries are safe under idempotency. Idempotency is the rule that repeating a request has the same effect as sending it once.

An unmatch deletes the match record. Either person can end it, and the pair leaves both stacks.

Deep dive: hot profiles and fairness

A small share of profiles draws a large share of views. Their accept lists grow far faster than average.

Hot profiles cannot sit in every stack at once. The builder spreads their appearances across viewers and time.

New profiles need a fair first chance. The builder gives each new profile a small set of early appearances.

Fake profiles and abuse arrive with scale. Reports remove a profile from stacks at once, while checks run.

Keeping stacks fresh

People move, pause and delete accounts. A stack built an hour ago can hold all three.

The stack refreshes when it runs low. A deleted or paused profile drops out at read time as a final guard.

Location updates change the pool slowly. The design rebuilds stacks on area change, not on every small move.

Evaluation and trade-offs

Prebuilt stacks trade freshness for speed. Read-time guards carry the freshness that prebuilding gives up.

The pair key trades a fixed storage order for safety. It is what makes one pair and one match the same thing.

Hiding passes trades information for safety. Nobody learns of a pass, so viewers can pass freely.

The match check sits on the accept path only. Passes stay cheap, and only accepts pay for the lookup.

Tinder in numbers

ItemFigure
Users100,000,000
Swipes a day1,000,000,000
Swipes a second11,574
Match rate1%
Matches a day10,000,000
Matches a second116

Exercise

What creates a match?