"Design Tinder" is a geospatial question that is secretly about two other things: never showing the same person twice, and detecting a mutual like correctly when both people swipe at the same instant. Candidates who answer only with "put users in a geohash" have solved a third of it.
The product is a stack of profile cards. You swipe right to like, left to pass, and if the other person has also liked you, it is a match. At a hundred swipes per person per day, the load is large, simple and extremely write-heavy. What the interviewer wants is the shape of each hard part: nearby candidates, exclusion of everyone already seen, and an atomic match.
The index behind "who is nearby" is covered in spatial indexing, and the "have I seen this person" test uses a Bloom filter. For a place-search variant of the geo problem, see Design Yelp.
Clarify the requirements
Functional requirements:
- Create a profile with photos, and set preferences (age range, distance, gender).
- Get a stack of nearby candidate profiles that match both people's preferences.
- Swipe right (like) or left (pass) on a candidate.
- When two people have liked each other, create a match and notify both.
- Chat with matches (treat as Design WhatsApp).
Out of scope, said aloud: chat internals, photo moderation, payments and boosts, verification, safety reporting.
Non-functional requirements: these decide the architecture.
- The next card is always ready. Swiping must never wait on the network. Prefetch the stack.
- No repeats. A profile you have swiped on must never come back, even months later.
- Matches are exact. If two people both liked each other, a match must exist, once. A missed match is a lost customer, and a duplicate is confusing.
- Locations are fresh enough, about a kilometer, not exact.
- Fairness. Everyone gets some visibility, so a few popular profiles do not absorb all the likes.
Estimate the scale
Assume 50 million daily active users, each swiping about 100 times a day. About 40% of swipes are right swipes, and about 1% of right swipes are reciprocated.
Swipes: 50M × 100 = 5 billion a day, or 58,000 per second on average, and about 175,000 per second at peak (3x).
Matches: 5B × 40% = 2 billion likes a day. 1% reciprocated is 20 million matches a day, or about 230 per second. Matching is rare compared with swiping.
Swipe storage: a record of two IDs, a direction and a timestamp is about 24 bytes: 5B × 24 B = 120 GB a day, or 44 TB a year.
Cards served: every swipe consumes a card, so about 58,000 candidate reads per second, served in stacks of 100: roughly 580 stack refills a second.
Seen filters: a Bloom filter for 10,000 previously seen profiles at a 1% false-positive rate takes about 12 KB. For 50 million active users that is 600 GB, spread over a cache cluster.
"175,000 writes a second of tiny records is a storage and partitioning problem, not a compute problem. Matches are 230 a second, which is nothing, but they have a correctness requirement the swipes do not. And the read path is not one query. It is a pre-built stack of candidates, filtered by geography, preference and history."
The capacity estimator reproduces the swipe and card rates and the 44 TB.
API and data model
GET /v1/candidates?limit=100 -> { cards[{userId, photos, name, age, distanceKm}] }
POST /v1/swipes [{ targetId, dir: like|pass, swipeId }] (batched by the client)
GET /v1/matches
PUT /v1/location { lat, lng } (throttled)profiles (user_id PK, prefs, photos, last_active)
swipes (pair_key PK = min(a,b)#max(a,b), a_dir, a_ts, b_dir, b_ts)
matches (match_id PK = hash(pair_key), users, created_at)
geo_index cell_id -> sorted set of active user_ids (in memory)
seen Bloom filter per user (+ durable swipes as the source)The non-obvious choice: both directions of a pair live in one record, keyed by the two user IDs in sorted order. That is what makes matching atomic, as the second decision explains.
High-level design
We simulate the read and write path: the app asks an API for candidates from an in-memory geo index and sends swipes to a durable swipe store, and match events flow through a queue to a notification service.
- The API serves candidate stacks from the in-memory geo index and records swipes in DynamoDB.
- Match events are published to Kafka, and a notifier tells both people.
Describe this diagram
Components
- app (Client)
- swipe api (Service)
- geo index (Redis)
- swipe store (DynamoDB)
- match events (Kafka)
- notifier (Service)
Connections
- app sends to swipe api
- swipe api sends to geo index
- swipe api sends to swipe store
- swipe api sends to match events
- match events sends to notifier
Run it, then try raising the load or switching the swipe store's capacity mode. The swipe table takes the write storm.
The write path: the client batches swipes and sends them in one request. The API writes each to the pair record with a conditional update, and if the update shows the other person had already liked, it creates the match and publishes an event.
The read path: the client holds a stack of about 100 cards and asks for more when it drops below 20. The API assembles the next stack in the background, as described next.
The interesting problem: building the candidate stack
A candidate must be nearby, mutually acceptable, active and unseen, and the answer must be ready before the user swipes again.
Approach A: query the database on demand
SELECT ... WHERE lat BETWEEN ... AND lng BETWEEN ... AND age ... AND id NOT IN (SELECT target FROM swipes WHERE user = ?).
Good: straightforward and always current.
Bad: a bounding box query on two columns is a poor use of a B-tree, the NOT IN grows with the user's history to tens of thousands, and 580 of these a second against a 100-million-row table hurts. Latency is unpredictable, exactly where the user is waiting.
Approach B: an in-memory geo index, filtered on read
Divide the world into cells with a geohash or S2-style grid, and keep a set of recently active user IDs per cell in memory. To serve a request, read the user's cell, add neighbor cells in rings until you have enough candidates, then filter by preference and by the seen set.
Good: the spatial query becomes a few memory lookups. Only active users are indexed, so the index is small: 50M active users at about 50 bytes is 2.5 GB.
Bad: a dense city cell holds millions of users, a rural one holds none, so ring expansion has to adapt. Filtering after the fetch can discard most of what was read when the user has already seen many people.
Approach C: a precomputed stack per user, refilled in the background
Keep a queue of about 200 ready candidates per active user. A background worker uses the geo index (B), applies mutual preferences, removes anyone in the seen filter and ranks the rest, then pushes them onto the queue. The API simply pops 100 cards.
Good: the user-facing read is a single fast pop, and expensive filtering and ranking happen off the critical path, in batches. A ranking model (see Design a Recommendation System) can improve who goes first.
Bad: a stack can go stale, as the people in it may leave, change preferences or move. Check "still active and not already matched" when serving, and refill on preference or location change.
The recommended answer is C built on B, with the seen test done by a Bloom filter per user: it answers "definitely not seen" or "probably seen" in microseconds from 12 KB. A false positive means skipping a good candidate at a 1% rate, which is harmless. The durable swipe table remains the source of truth, and the filter is rebuilt from it.
The second decision: detecting a match without a race
Alice likes Bob and Bob likes Alice, within the same second, handled by two different servers. A naive design writes Alice's swipe, then reads Bob's, and Bob's server does the mirror image. If each write is not yet visible to the other server's read, both see no like and no match is created.
The fix is to put both swipes in one record, keyed by the sorted pair of IDs. Each swipe is a conditional update of its own side: SET a_dir = like WHERE ..., returning the new state of the whole record. The database serializes updates to one record, so one of the two updates is applied second, and that one sees the other person's like in its returned record. It creates the match. The other sees only a one-sided like and does nothing.
Creating the match is idempotent: the match ID is a hash of the pair key, and insertion is conditional on not existing, so a retry or a double execution cannot create two. This is the idempotency pattern applied to a rare, important event. A match then publishes an event, and notification is a separate, retryable step.
Bottlenecks and failures
A hot profile. A popular person receives millions of likes. Because swipes are keyed by pair, there is no single hot row, and the writes spread across the table. The profile read is cached.
Density skew. One cell contains most of a city. Use adaptive cells, subdividing when a cell holds more than a threshold of active users, and cap the candidates per request.
The swipe store is unavailable. Queue swipes on the client and in a stream, return success to the user and replay later. Matches are delayed, never lost. Do not show a "match" until the record confirms it.
Running out of people. In a small town a user can see everybody in an afternoon. Widen the radius gradually, show "no more nearby" honestly, and let people re-see passed profiles after a long period if the product wants it, which means expiring old passes from the seen filter.
What if the geo index is down? Fall back to the last known stack the client has, and refill from a coarser database query for the user's city. Quality drops, and swiping continues.
Trade-offs to name aloud
- Precomputed stacks: instant swipes and cheap peaks, at the cost of occasionally stale candidates.
- Bloom filter for seen: tiny and very fast, and a 1% chance of hiding someone new. The swipe table remains the truth.
- One record per pair: atomic matching with no distributed transaction, and a key design that serves only pair lookups.
What interviewers listen for
- A working answer: a geospatial index for nearby users, a swipe table and a match check when a like is recorded.
- A strong answer: a prefetched candidate stack, a Bloom filter or equivalent for seen profiles, and a conditional update on a pair record so matches are exact.
- A standout answer: also builds the stack off the critical path, handles density with adaptive cells, throttles location updates, makes match creation idempotent, discusses visibility fairness and degrades gracefully when the geo index fails.
Check your understanding
Common mistakes
Stopping at "use a geohash". The nearby query is the easy third. Seen filtering and matching are where the points are.
Storing swipes in two tables. Separate "likes by A" and "likes by B" records are exactly what creates the race. Key by pair.
A NOT IN over the swipe history. It grows without bound for active users. Use a filter and apply it after the geo lookup.
Writing every location update. It floods the index with changes that nobody can see. Throttle by distance and time.
Practice
A user changes their maximum distance from 10 km to 100 km. What happens to their candidate stack, and what do you do in the system?
Write your own answer first, on paper or in a note. Then compare.
Show a hint
Consider what is already queued, and what the new request means for the geo lookup.
Show a strong answer
The old stack is wrong in one direction. Nothing in it violates the new preference, since all are within 10 km, but the user now expects farther candidates. The stack is valid and merely too narrow.
Invalidate and refill. On a preference change, mark the stack stale and enqueue a refill. Serve the remaining cards while the new ones are built, then mix in the farther candidates. Dropping the old stack at once would leave the user waiting.
Expand rings, not the query. The geo lookup reads rings of cells outward until it has enough candidates, so a larger radius is just more rings. Cap the number of cells per refill, and prefer closer candidates first.
Mind mutual preferences. A candidate 80 km away who set a 20 km limit should not appear. Both people's constraints must hold, so check the candidate's limit against the distance.
The pattern worth keeping: treat a preference change as an event that invalidates a precomputed view, and refill it without blocking the user.
The match notification fails for Bob because his push provider is down, and Alice sees the match but Bob does not. How does your design recover?
Write your own answer first, on paper or in a note. Then compare.
Show a hint
Separate creating the match from telling people about it.
Show a strong answer
The match is already durable. The pair record and the match row were written before any notification. Bob's app reads the match list from the API, so opening the app shows it whether or not a push arrived.
Notifications are retried from the event. The match event stays in the queue, and the notifier retries with backoff. If push fails for good, a lower-priority channel (email, or an in-app badge on next open) can take over.
Show consistent state. Alice's app should not claim "Bob is waiting" before the match exists, and should show what the server confirmed.
The pattern worth keeping: make the important fact durable first, and treat notification as a retryable, idempotent side effect that never defines the truth.
Key takeaways
- Three problems: nearby candidates, never repeating a profile and exact matching.
- Use an in-memory geo index of active users, with adaptive cells for dense cities.
- Precompute a candidate stack per user and filter seen profiles with a Bloom filter.
- Key swipes by the sorted pair, so a conditional update gives race-free, idempotent matches.
- Throttle location writes, and batch swipes from the client.
- Make the match durable before notifying, and retry notifications.
Further reading
- B. H. Bloom, "Space/Time Trade-offs in Hash Coding with Allowable Errors", Communications of the ACM (1970): the original Bloom filter.
- Redis documentation, "Geospatial indexes" and "Sorted sets": in-memory structures for nearby lookups.