Engineering stories behind the Medium Daily Digest Algorithm: Part 2

Raphael Montaud9 Sep 2025

Problem

Medium's feed builder sources up to 5000 candidate stories per user and must drop muted writers, read stories and stories shown three or more times. That is about 15,000 membership questions per feed and more than 15 million per second. Bloom filters answered them cheaply, but they grew to billions of items. They could not delete entries, could not be inspected, and duplicated data already held in databases.

Example from the article: a user who unmutes a writer stays muted forever in the Bloom filter, and the filter cannot be cleaned or debugged.

Solution in brief

Replace each Bloom filter with a direct query of the user's own records (mutes, presentations, reads) in the source database, then cross-reference with the shortlist. Heavy users get a best-effort cap of the last 5000 records where the rule is soft, and a two-stage filter where it is hard. Filtering costs fall ten times.

Questions this case answers
  • How to exclude seen, blocked or consumed items from a candidate list at low cost when a probabilistic membership filter has grown too large and cannot delete entries
  • How to enforce a hard exclusion rule for users with very long histories when fetching the full history in real time is too slow
  • How to filter already-read, muted and over-shown stories out of a feed without Bloom filters?
  • How to count how many times an item was shown to a user when the user's history is too long to fetch in real time?

Tools and methods

  • User-based direct queries — fetch all of one user's records and filter the shortlist in memory instead of asking per (user, item) pair.
  • Best-effort history cap — read only the most recent 5000 presentations for the soft frequency rule.
  • Two-stage read filter — bulk early filter on the last 5000 reads, pairwise check at the final stage on about 10 posts.
  • DynamoDB — the database holding mutes, presentations and reads, queried per user.
Continue reading — it's free

Google or a one-time email code. No password.