System Design AI

Design a dating app like Tinder: the junior, senior and staff answer

A dating app looks simple: show nearby people, swipe left or right, tell both people when they like each other. The interesting part is that one of those features has to be exactly right at enormous scale, while the others can be approximate.

Requirements to pin down

  1. People create a profile with preferences: who they are interested in, an age range, interests and a maximum distance.
  2. They see a stack of nearby people who fit their preferences, and whose own preferences fit them back.
  3. They swipe right (like) or left (pass), one card at a time.
  4. When two people have liked each other, both are told.

The non-functional requirements are where the design comes from. The worked design sets:

  • A match is never lost: strong consistency per pair. The second of two likes always finds the first.
  • The stack is instant: under 300 ms at p99.
  • Swipes at firehose scale, each acknowledged in under 100 ms.
  • Nobody is shown twice. Hiding a few extra people by mistake is acceptable; showing someone again is not.

The numbers

  • Swipes: 20 million daily users x 100 swipes = 2 billion a day, about 23,000 a second on average (2,000,000,000 / 86,400). Evenings run about three times that: roughly 70,000 a second.
  • Swipe data: at about 100 bytes a swipe, 200 GB a day.
  • Matches: about one per 80 swipes, so 25 million a day, roughly 300 a second.

Swipes dominate writes; stack loads dominate the latency budget; matches are rare but must be exact.

The core trick: one record per pair

The naive model stores each swipe as a row (swiper, target, like). When I like you, the service checks whether there is a row saying you liked me.

That is check-then-act, and it has a race. If we like each other in the same instant, both requests can check before either writes, both see nothing, and the match is never announced.

The fix is to keep both halves of the pair in one record. Key it by the two user ids in sorted order, so my swipe and yours land on the same item. Each like is a single atomic update that sets my half and returns the whole item. The store applies updates to one item one at a time, so one of the two likes always runs second, and it sees both halves.

The junior answer

  • Profiles and preferences in a relational database with a geospatial extension, so the stack is one query that filters by distance and by both people's preferences.
  • Swipes in a key-value store, one item per pair, updated as above.
  • A push notification to the first liker when a match is made.
  • Where it stops, with numbers: dense cities, where a single query must find and sort tens of thousands of nearby candidates on every open.

What a senior answer adds

  • Strong consistency per pair, named as the requirement, and the race closed with one atomic operation, with an explanation of why it works.
  • Stacks built ahead of time. A search index for location is fed by a change stream from the profile store, and builders precompute each person's next cards into a cache, so opening the app is a cache read. The candidate says when a cached stack goes stale, for example when someone changes their preferences.
  • A seen filter with the right error direction. A Bloom filter can wrongly answer "seen" but never wrongly answer "not seen". That means its only mistake is hiding someone, which the requirements allow. About 10 bits per swipe gives roughly a 1% false-positive rate.
  • Numbers for each piece, including the memory the filters need.

What a staff answer adds

  • Regions without breaking the guarantee. Multi-region tables that accept writes everywhere resolve conflicts by last writer wins, which could silently drop one half of a pair. So every pair gets one home region that decides its matches.
  • Proof, not just design. A regular audit compares acknowledged swipes with the pair records, repairs anything missing, and counts the repairs. Zero is the target.
  • Geo partitioning that survives density. Cells on a space-filling curve, cut so each shard holds a similar number of active people, rather than a fixed grid that puts a whole city in one square.
  • Abuse and privacy as inputs. Bots that like everyone, fake profiles and scrapers. And exact distances can locate a person by triangulation, so locations are snapped to coarse cells and distances shown in whole kilometres.

Mistakes that sink this question

  • Checking for the reverse like, then writing: the race above.
  • Treating every feature as strongly consistent. Only the pair needs it; stacks can be stale.
  • A seen filter that can say "not seen" wrongly, so people reappear.
  • Keying swipes by the person being swiped on, so one popular profile becomes a hot partition.
  • Forgetting the first liker, who is not on the request that made the match and has to be notified.

Practise it

Read the free worked design, Design a Dating App like Tinder: start with the board for your level. Before you open it, spend ten minutes on the swipe race alone and convince yourself your version cannot miss a match.

With Pro ($10/month) you can draw your answer on the practice canvas and get an AI review against the rubric.

Questions people ask

Could Redis decide the match instead of the database?

Yes: a script that sets one half of a pair key and returns both is atomic too. But you still need the swipe written durably, a way to evict about 200 GB of pairs a day from memory, and a plan for likes lost when a primary fails before replicating. If the durable store can decide the match in the same write, use it.

Why is it acceptable for the seen filter to hide people by mistake?

Because the requirement is asymmetric. Showing someone a person they already swiped on is a visible bug; hiding a few people they have not seen costs almost nothing when the stack has many candidates. A Bloom filter is wrong only in the acceptable direction.

How does the first person who liked find out about the match?

The second liker learns from the swipe response. The first is on no request at that moment, so a consumer of the pair table's change stream notices a pair go from one like to two and sends them a push.