Ranked and Funny: Building a System for Arranging a User Feed

Kirill1 Aug 2023

Problem

A product team builds a user feed on item metadata that arrives continuously from another team, under heavy read traffic. The feed must be partly personalized, moderated, and show items from several groups in set proportions. Sending every request to the search store overloads it. The scoring formula keeps changing, so parameters must be adjustable without a release. An ML-only feed is slow to tune and hard to use in real time.

Illustrative example: the author designs a feed of user-submitted jokes, with 200–500 new items per day and 8–12 items read per user per session. The product is invented, not an Ozon feature.

Solution in brief

Store item metadata in Elasticsearch behind one service. Build several in-memory pools from fixed queries (new, hot, top, authors, length class) and refresh them every 30 minutes. A feed service draws from the pools in the requested proportions and drops duplicates by ID. An ML recommender and an editorial list join as two more streams behind the same blending service.

Questions this case answers
  • How to compose a ranked feed from several candidate sources with fixed proportions and no duplicates under high request load
  • How to run a rule-based feed and an ML recommender side by side so that either can serve the feed and the two can be compared
  • How to assemble a personalized feed from several candidate groups with fixed content proportions?
  • How to keep a feed free of duplicates when one item can come from several sources?

Tools and methods

  • Elasticsearch — metadata store with filters and relevance scoring
  • Pool pattern — pre-built in-memory groups of items, one per ranking criterion
  • Scoring ("cost") — numeric item score from a formula with tunable coefficients
  • Redis — flag and counter that synchronize pods writing to HDFS
  • Apache HDFS, PostgreSQL — exchange with data science and serving of ML results
  • Grafana — pool and request metrics for managers
Continue reading — it's free

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