Tinder
Location-based dating app
Design a dating app that shows each person a stack of nearby profiles, records a like or pass on each, and creates a match the moment two people like each other.
Overview
A swipe-based dating app shows each person a stack of profile cards, one at a time. The person likes or passes on each card. When two people have liked each other, the app announces a match and opens a conversation.
The stack is a search problem: find people within the user's chosen distance who fit both sides' preferences (age, gender), whom the user has not seen before, and put the most promising first. The swipe is a write problem: billions of small writes a day, and a check on every like for the other side's like. Location ties them together: the search index is split by geography, and people move.
Questions to ask first
- How many users and swipes? — 20 million daily users, 100 swipes each a day
- How far can people search? — Up to 100 miles, set per user
- Must a match be instant? — Yes: the second like returns the match in its response
- Can a profile be shown twice? — No, once swiped it never comes back
- How is the stack ranked? — By likely mutual interest; the model is out of scope, the pipeline is in
- Moving to another city? — Yes; the user must show up there within seconds
What you will be able to do
- Find nearby users with S2 cells and a covering of the search circle.
- Split a search index by geography so the shards carry equal load.
- Build a card stack: candidates, filters, the seen filter, ranking, caching.
- Detect a mutual like exactly once, even when both likes arrive together.
- Keep the index correct when users move between shards.
Key concepts
- Geospatial index
- S2 cells
- Geosharding
- Load score
- Candidate generation
- Seen filter (Bloom filter)
- Mutual match
- Atomic upsert
- Write ordering
Functional requirements
- Create a profile with photos, age, gender and the preferences you want to see
- Get a stack of nearby profiles that fit both people's preferences
- Like or pass on each profile; never see it again
- Get a match, with a notification, when a like is mutual
- Update location; appear to people in a new city
Non-functional requirements
- A swipe returns in under 100 ms at p99, including the match check (a target we chose)
- A card stack loads in under 300 ms at p99 (a target we chose)
- Two mutual likes produce exactly one match, even at the same instant
- A user who moves appears in the new area within about 10 seconds (a target we chose)
- A profile already swiped is never shown again
Interview questions
- How do you find people within 20 miles quickly?
- How would you shard the search index?
- Both people swipe right at the same moment. What happens?
- How do you make sure nobody is shown twice?
- How is the stack ranked? Is it Elo?
- A user flies to another city. How do they show up there?
- What is the heaviest load, and how do you handle it?
Sign up free to read the full topic
More System Design topics
Start free on Cariara · Coding problems · System design studio