Design Tinder (Dating App)
medium 60 minShow people nearby, record a yes or a no, and tell both when the yes is mutual.
Video lesson · Chapter 1 of 5
One swipe and no match
Theory
Read or listen first. About 2 min.
What it is
A dating app like Tinder shows one profile at a time. The member says yes (a like) or no (a pass). When two members have each said yes to the other, that is a match, and only then can they write to each other.
Behind that gesture are three systems: one that picks whom to show (the deck), one that records answers and finds matches, and one that delivers matches and messages. They have different loads and need different promises.
Why it exists
The swipe turns a long profile search into one quick question. It also hides a no: nobody learns that they were passed, which is why the server, not the phone, must keep likes and compare them.
It is a good interview problem because the easy parts are large and the hard part is small. A billion swipes a day is only disk and partitions. Never missing a mutual like is a question about ordering, and many fast designs get it wrong.
A short history
1960
The US Chess Federation adopts Arpad Elo's rating system, later borrowed for ranking in many other fields.
2008
Gustavo Niemeyer publishes geohash, which turns a latitude and longitude into a short string.
2012
Tinder launches after a hackathon prototype called Matchbox.
2019 and later
Tinder says on its own site that Elo is "old news" and that its matching no longer relies on it.
Words to know
- Deck
- The ordered list of profiles a member will be shown next.
- Like and pass
- A yes and a no. A super like is a yes that the other person is told about.
- Match
- Both members of a pair have liked each other.
- Pair key
- The two member ids in a fixed order, so both sides compute the same key.
- Geohash
- A code for a rectangle on the map. Adding a letter makes the rectangle smaller.
- Bloom filter
- A small memory structure that says "certainly not seen" or "probably seen".
- Quorum
- A majority of copies. A quorum write and a quorum read of the same copies always share at least one.
Solve it like an interview
New to it? Start with Approach. Revising? Go straight to the mock.
- 1ApproachWhat this question tests, where it gets hard, and how to spend the time.
- 2ScopeAsk what changes the design, then commit to a short list.
- 3NumbersWork out a number when the answer changes what you build.
- 4API and dataThe contract first, then the data that serves it.
- 5DesignStart with the smallest system that works. Change it only when something breaks.
- 6Deep divesCompare the options before you open them, then say which you would pick.
- 7Explain your choicesAnswer first. Then compare your reasoning.
- 8By levelThe same question is judged differently for mid, senior and staff.
- 9MockAnswer against the clock, then score yourself.
How it works
Step through the idea, or press Play.
Build a deck. People nearby who fit both sides' wishes and have not been seen
Understand it
Scope
What are we building?
A service like Tinder: profiles with photos, a deck of people nearby, like and pass, matches, and a chat that opens after a match. This page is an exercise inspired by well-known products. It does not describe any company's real system.
Similar applications
| Service | Known for |
|---|---|
| Bumble | Time-limited matches |
| Hinge | Profiles built from prompts |
| OkCupid | Compatibility from questions |
| Grindr | Location first, quick messages |
| Coffee Meets Bagel | A small daily selection |
| Happn | People whose paths you crossed |
The hard part
Never lose a mutual like
Suppose both people press like in the same instant. If each request first asks "did the other one like me?" and then writes, both can be told no. Two likes are stored and no match ever appears. Nobody sees an error, so nobody reports it.
Read first: the match is lost
The finished system
Where the design ends up
This is the last version. The Design tab starts with one service and one database and shows which number forces each extra box.
The whole system
Four key ideas
One key per pair
Both likes land in one partition, so one small read answers the question.
Write, then read
The second writer always sees the first. The match id is computed, so two creators make one match.
Decks on demand
Build the next hundred cards when a member is nearly out, not on a timer for everyone.
Blur the distance
Precise distances can reveal a home. Round on the server.
Where to go
The tabs and the concepts
| If you want | Open |
|---|---|
| What the interviewer looks for | Approach, By level |
| Targets and sums | Scope, Numbers |
| Endpoints and tables | API and data |
| Matching, decks, distance, fairness | Deep dives |
| Practice against the clock | Mock |
| Quorums and copies | Consistency models, data replication |
| Safe retries | Idempotency |
| Live delivery | Real-time APIs, pub-sub |
| Photos at the edge | CDN, object storage |
Summary
The whole topic in one minute.
The product is a loop: build a deck of people nearby, record an answer, look for the answer in the other direction, tell both people.
The design puts both likes of a pair in one partition, writes before it reads, and creates the match under an id that both sides compute alike. Decks are built when a member needs one, photos come from the edge, and everything after the match is an event.
- A swipe is two ids and an answer. Volume is easy; order is hard.
- Store both likes of a pair together, write before reading, and give every pair one home region.
- A computed match id makes creating and announcing safe to repeat.
- Build decks when they are needed. Doing it for everyone each 15 minutes costs about 32 times more.
- Notifications can be late. The match row is the truth.