Concept study · Backend architecture

Creator Fan Community: fan-out that does not make creators wait

A redesign exercise for the feed behind a creator and top-fan platform: how a single post reaches every fan quickly, without slowing the creator down or breaking for creators with huge audiences.

My role
Backend engineerOn the platform since Mar 2024
Stack
  • Node.js
  • AWS Lambda
  • DynamoDB
  • Streams
  • SQS
Live product
topfan.com

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

The problem

On a creator platform a post is written once and read by many fans. The feed has to feel instant for the creator who publishes it and fresh for every fan who follows them. Two things make that hard: audience sizes vary from a few hundred fans to hundreds of thousands, and creators tend to publish in bursts.

  • The creator should get a reply in well under a second, however big the audience is.
  • Fans should see the post within seconds, not minutes.
  • A burst from one popular creator must not slow down everyone else.
  • A failed write for one fan must be retried without repeating the whole post.

The naive flow

The simplest design writes the post and then writes one feed item per fan before replying. It works well for small audiences and degrades with every follower.

The reply waits on the slowest step, which grows with audience size.

The re-engineered flow

Split the work in two. The request stores the post and answers immediately. A stream of changes from the table then drives the fan-out in the background, in small batches that retry on their own.

Write path

Read path

Posts from very large creators are merged in when the feed is read, instead of being copied to every fan.

Try it: what a post costs

Move the slider to change the creator's audience and compare the two designs.

Before: write to every feed, then reply

Creator waits for1.3 s
Feed write calls127
Fans see the post after1.3 s

After: reply first, fan out in the background

Creator waits for40 ms
Feed write calls127
Fans see the post after260 ms

Normal audience: the post is pushed into each fan feed.

Assumptions behind these numbers
  • Base request cost of 40 ms for the post write and validation.
  • Feed items are written in batches of 25, each batch call taking about 10 ms.
  • Before: batches run one after another inside the request, and the gateway gives up after 29 seconds.
  • After: 100 workers run in parallel, with about 200 ms for the stream and queue hop.
  • Audiences above 10,000 fans switch to pull on read.
  • This is a teaching model, not a measurement of any production system.

Design decisions and trade-offs

Reply first, fan out later

The creator's wait no longer depends on audience size. The cost is that a fan may see a post a moment after the creator does.

Drive fan-out from the change stream

Writing the post is the only step the request owns. The stream guarantees the fan-out sees every post, so no separate publish step can be forgotten.

Queue between fan-out and writers

Batches are retried independently and the queue absorbs bursts. A dead-letter queue keeps repeated failures visible instead of lost.

Push for most, pull for the very large

Copying a post to a million feeds is wasteful. Above a threshold the feed reads big-creator posts directly, which adds a small cost on read but removes the write storm.

Make every write safe to repeat

Feed items use a key built from the fan and the post, so a retried batch overwrites itself rather than creating duplicates.

What I would measure next

  • Time from publish to the last fan feed updated, split by audience size.
  • Queue depth and the age of the oldest message during a burst.
  • Dead-letter queue volume, with an alarm on any growth.
  • Feed read latency before and after merging big-creator posts.