Concept study · Backend architecture

Influencers Platform: discovery that stays fast as the catalog grows

A redesign exercise for how a creator marketplace helps people find the right match: fast, personalised search and recommendations over a catalog of profiles that keeps growing.

My role
Backend engineerFeb 2023 to May 2024
Stack
  • Node.js
  • Express
  • MongoDB
  • Elasticsearch
  • Redis
  • S3
Live product
lvrgd.com

About this study. This is my own re-architecture exercise, built from the public behaviour of the product and the services I worked with. It is not the product's internal design, and every number on this page comes from the model in the simulator below, not from production.

The problem

People arrive wanting to find creators and communities that match their interests. Results have to appear quickly, feel personal, and stay current as profiles are added and edited, even while the catalog grows from thousands of profiles to hundreds of thousands.

  • Search results should appear in well under a second, whatever the catalog size.
  • Recommendations should reflect the visitor, not just the query.
  • A new or edited profile should become searchable within seconds.
  • Traffic spikes on popular searches must not slow the rest of the platform.

The naive flow

The simplest design filters and scores profiles in the database on every request, then fetches media for each result. It is easy to build and slows down with every profile added.

Every search pays for the whole catalog, so the wait grows with its size.

The re-engineered flow

Separate the system of record from the system of search. The database stays the source of truth. A search index answers queries quickly, a cache absorbs repeat searches, and a small re-rank step makes the top results personal.

Search path

Update path

Ranking features such as interests and activity are prepared when a profile changes, so a search only has to look them up.

Try it: what a search costs

Change the catalog size and how often searches repeat, then compare the two designs.

Before: scan and score in the database

Search takes1.2 s
Profiles examined100,000
New profile searchable afterImmediately

After: index, cache and personal re-rank

Search takes43 ms
Candidates re-ranked50
New profile searchable afterAbout 2 s

The trade-off: a brand-new profile takes a moment to show up, in return for results that stay fast at any size.

Assumptions behind these numbers
  • Before: 30 ms of base work, plus 0.012 ms to filter and score each profile.
  • After, on a cache miss: 25 ms for the index, plus 2 ms each time the catalog doubles, plus 10 ms to re-rank the top 50.
  • After, on a cache hit: about 5 ms. The average blends hits and misses by the repeat share you choose.
  • Index lag of about 2 seconds covers the change event, the indexer, and the index refresh.
  • This is a teaching model, not a measurement of any production system.

Design decisions and trade-offs

Database for truth, index for search

Each store does what it is good at. Writes and edits go to the database. Queries go to the index, which is built for filtering and ranking text and tags.

Prepare ranking features at write time

Interest tags and an activity score are computed when a profile changes. A search then reads ready values instead of computing them for every candidate.

Rank in two stages

The index returns a few dozen strong candidates cheaply. Only those are re-ranked with the visitor in mind, which keeps personalisation affordable at any catalog size.

Cache popular searches briefly

A short cache lifetime absorbs spikes on popular queries. Any profile change purges the entries it could affect, so results do not stay stale.

Keep media in object storage

Images live in object storage and are served in a few sizes, so a results page loads small thumbnails instead of full files, and the API never streams media itself.

What I would measure next

  • Search latency at the 95th percentile, split by catalog size.
  • Cache hit rate and how much of it comes from the top searches.
  • Index lag: the time from a profile change to it appearing in results.
  • Zero-result searches, and clicks on personalised results versus plain ones.