Components · AI pipeline

Ranking model

Scores candidates for a feed, recommendations or search (a learned ranker on CPUs or GPUs).

Lesson
Coming soon
Zone
ai
Place it
8 cr on the blank canvas, free inside a problem

At a glance

Did you know
Feeds rank a few hundred candidates per load with a learned model; retrieval narrows millions of posts first.
Rule of thumb
Keep ranking off the write path: rank at read time from a precomputed candidate list.
Watch out
Called on every feed load: CPU-bound and on the hot path; a slow ranker slows every feed.

Its settings in ScaleMySystems

What you can change on it in the lab, and what each number does.

Concurrency (slots)
Calls it can work on at once (per instance when autoscaling). Needed slots ≈ calls per second × seconds each takes. Extra calls wait in the queue, then are rejected.
Queue capacity
Calls allowed to wait for a free slot. A bigger queue absorbs bursts but adds waiting time; 0 rejects straight away.
vCPU
CPU cores available. Needed ≈ calls per second × CPU per request ÷ 1000. Above about 90% busy it slows down and may crash.
CPU per request (ms)
CPU time each call burns. Part of what the component is; make the code cheaper to lower it.
Latency (p50) (ms)
Typical time one call takes here, before any calls it makes itself. Slots are held for this long.
Latency (p99) (ms)
The slowest 1% of calls. Callers must set their timeout above this or they cut off healthy calls.
Timeout to dependencies (ms)
How long it waits for each call it makes before giving up. Set it above the dependency’s p99 but low enough that a dead dependency does not hold every slot.
Error rate
Share of calls that fail on their own (bugs, declines, flaky tools). An agent that calls it on every step multiplies this.
Quota (req/min)
Calls allowed per minute (an API key or provider limit). Calls over it get 429s. Needed = calls per second × 60, with headroom.

Problems that start with it

  • Instagram: from launch build to real traffic Instagram as a small team first shipped it: no timeline or profile cache, no media CDN, and every service an eighth of its real size. Real traffic arrives: 4,000 requests a second, 70% feed loads, 10% profiles, 15% likes and 5% new posts with photos to resize. Feeds time out and photos stall.
  • Facebook news feed: from launch build to real traffic The news feed as first built: no feed cache in front of the timeline store, and the feed API, ranking model, social graph and fan-out workers at an eighth of their real size. 5,000 requests a second arrive: 85% feed loads that are ranked on every load, 15% new posts fanned out to followers. Most feed loads fail.
  • Netflix: from launch build to real traffic Netflix without Open Connect or EVCache: every request reaches the origin, title metadata is read from the catalog database each time, and the playback, browse, license and recommendation services are an eighth of their real size. 6,000 requests a second: half are playback starts, 45% browsing, 5% DRM licenses. Playback starts fail.
  • Twitter / X timeline: from launch build to real traffic The home timeline as first built: timelines read from Manhattan with no Redis cache, and the timeline API, ranker, tweet API, fan-out workers and search at an eighth of their real size. Real traffic of timeline reads, new tweets and searches arrives, and most requests fail.
  • Amazon storefront: from launch build to real traffic A storefront as first built: product pages read DynamoDB with no product cache, and the product, cart and checkout APIs, search, recommendations, the orders database, payments and fulfilment workers at an eighth of their real size. Shoppers arrive at real traffic and half of all requests fail, checkout included.

Full lesson coming soon

Lessons are being added one component at a time: how it works, its settings, a live exercise to break and fix it, interview questions and a short check. See the Circuit breaker lesson for what one looks like.