Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active April 1, 2024 03:51
Show Gist options
  • Select an option

  • Save wilmoore/aa2f293386c8f92cc2fc2fe4e124f55c to your computer and use it in GitHub Desktop.

Select an option

Save wilmoore/aa2f293386c8f92cc2fc2fe4e124f55c to your computer and use it in GitHub Desktop.
Software Engineering :: System Design :: Newsletters :: Neo Kim's System Design Newsletter :: How Tinder Scaled to 1.6 Billion Swipes per Day

Software Engineering :: System Design :: Newsletters :: Neo Kim's System Design Newsletter :: How Tinder Scaled to 1.6 Billion Swipes per Day

⪼ Made with 💜 by Polyglot.

Tinder Architecture

Here’s a simplified version of Tinder architecture:

Chapter 1: Get Over the Breakup

Kenji creates a Tinder profile and adds extra information.

Creating a User Profile Creating a User Profile

They store the user information in a key-value database like Amazon DynamoDB. And use Dynamo Streams to push out changes on a table to different places automatically.

Also the user information gets added to the message queue to update the location index. They use the location index to find nearby users efficiently.


Public Traffic Routed Through API Gateway Public Traffic Routed Through API Gateway

They provide public APIs through an API Gateway. That means it acts as a central entry point for user requests to the infrastructure. And handles user authorization and security rules.

They run around 500 microservices. And use service mesh to communicate between the services. Imagine service mesh as a network infrastructure for managing microservices communication efficiently.

Chapter 2: The Lady From Okinawa

Kenji is shown Tinder profiles of people living nearby.

It’s difficult to find nearby people only based on a person’s latitude and longitude values.

Also they don’t divide the world map into evenly spaced grids to avoid the hot-shard problem. Because the grids in the ocean will be empty. While grids in big cities will have many users. A hot shard is an excessive load on a single partition.

Instead they use the S2 library. S2 is a square-shaped hierarchical geospatial indexing system created by Google.

It’s a stable library supporting many programming languages. Put another way, they use S2 to recommend people in real time and shard the location database.

Representing the World Map Using S2 Cells Representing the World Map Using S2 Cells

S2 divides Earth’s surface into cells on a flat grid, giving each cell a unique identifier with a 64-bit integer. In other words, a small cell represents a small area of the earth.

They store the users physically closer to each other in the same database shard. Thus reducing the need to query many shards to find nearby users.

And S2 is hierarchical. That means the cell size varies from square centimeters to square kilometers.

Als it supports finding a specific cell using the latitude and longitude. And provides the functionality to find the surrounding cells of a specific cell.


S2 is based on the Hilbert curve. Imagine the Hilbert curve as a line that covers every point in a square by folding and looping in a special way. While two points that are close in the Hilbert curve are also close in physical space. That means it preserves spatial locality.

Each small Hilbert curve represents an S2 cell. While four adjacent cells form a bigger cell, and a quadtree represents a 2D Hilbert curve. A quadtree is a tree data structure where each node has exactly four children.


Finding Nearby Users Finding Nearby Users

They query the location index (S2) to find nearby users. It returns all the database shards close to a specific location. After that, they query all the relevant database shards in parallel to get the list of users in those shards.

On average they query 3 database shards to find nearby users within a 160 km radius. Also they filter the results based on user preferences before recommending people.


Kenji meets up with a lady from Okinawa.

But it didn’t work out because she wasn't interested in a long-distance relationship.

Chapter 3: Okinawa to Sydney

Kenji thought matching on Tinder with someone in Sydney, Australia would make more sense.

So he uses Tinder’s feature called Passport to change his location.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment