Social & feeds
Reviews and ratings - the average that must not be gamed
Why a star rating is an aggregate maintained on write, and how fake reviews are held back before they count.
What this board gets wrong on purpose
The tension
The aggregate is maintained by deltas and repaired by a nightly recount, so for up to a day the number on the page can be off by whatever the delta pipeline dropped or doubled - and nobody is alerted unless the recount finds a gap larger than its threshold. The bigger gap is in time. The trust scorer catches most fake reviews before they count, but a review ring is often found weeks later, when its accounts are linked; removing 400 five-star reviews then corrects the average today, after the product spent those weeks ranked on the inflated number and the seller kept every sale it made. Nothing on this board claws that back or even records what the rating WAS while it was wrong. And holding reviews costs honest reviewers too: the 3% that go to a human wait a median of 18 hours, and a product with a real defect collects its one-star reviews in the hold queue while the page still says 4.7.
Practise this as an interview
Take Reviews and ratings - the average that must not be gamed as a timed system design interview on a blank board - on your own, with the requirements to check yourself against, or with a candidate you invite.
Start here
Why this design
A star rating looks like an AVG() and is really a small ledger: a sum, a count and a histogram per product, maintained by deltas as reviews enter and leave the set that counts - and that set is defended, because every seller and competitor has a reason to change it. Interviewers use it to test write-time aggregation, idempotent event application, and whether you put moderation BEFORE the number rather than after.
What you will learn
- Why "4.6 from 12,408" is two integers read from one row, not 12,408 rows averaged on every view.
- Why a new review is PENDING and only PUBLISHED reviews move the aggregate.
- Why the trust scorer is a fan-out over four signals and answers publish, hold or reject.
- Why each delta carries a per-product sequence number, so it applies exactly once.
- Why a nightly recount exists, and what it can and cannot repair.
- Why ranking uses a Bayesian average, so a product with one five-star review does not outrank one with 12,408 at 4.6.
How to read this board
- Press play once: the walkthrough follows one review from submit to the number on the page.
- WRITE: verify, score, hold or publish.
- AGGREGATE: state changes become deltas on one row per product.
- READ: the page and search ranking both read that row and nothing else.
- DATA MODEL: reviews with the star value they currently contribute, and the aggregate row.
- Then pages 1 to 6 in order: requirements, capacity, storage, availability, how it works, deployment.
1 · Requirements
A shopper wants a number they can trust in under a second. A seller wants that number to go up. The system's job is the first one despite the second.
Ask these before designing
- Who may review? Anyone, or only buyers? "Verified purchase" is usually a badge and a trust signal, not a gate - gating loses gifts, in-store purchases and returns.
- How fast must a review appear? Seconds for most is expected. A minority held for hours is the price of not publishing fakes.
- Can reviews be edited? Yes - and an edit from 5 to 2 stars must move the aggregate by -3, exactly once.
- What does the page show: mean, histogram, or both? Both, and search ranks on something else (a Bayesian average).
- What happens when fraud is found later? Reviews are removed and the aggregate is corrected. Is the history of the rating kept?
Functional
- Submit one review per user per product: 1-5 stars, title, text, optional photos.
- Score every review for trust; publish, hold for a human, or reject.
- Show the rating, the count and a five-bar histogram on every product page.
- Show the top reviews sorted by helpfulness; users vote helpful.
- Edit and delete your own review; moderators remove reviews.
- Rank search results by a rating that resists small samples.
Non-functional
- Product page rating read p99 under 20 ms, at 70,000 page views/s peak.
- 85% of reviews published within 10 s of submit; held reviews decided within 24 h.
- Aggregate exactly right after the nightly recount, and never more than 0.5% of count off before it.
- Every state change applied to the aggregate exactly once.
- Read availability 99.99%: a page without stars converts measurably worse.
Out of scope
Q&A, seller responses, photo moderation models, review syndication between sites, incentivised review programmes.
The rest of this board
Available on Tier Slate
This page publishes the question. The answer — 5 more written pages, an 8-step narrated walkthrough and a 5-table schema — is the board itself, and it opens in Tierslate.
- 5written pages
- 8walkthrough steps
- 5tables36 columns
5 pages behind this one
- Capacity estimation
- Storage estimation
- Availability
- How it works
- Deployment plan
More boards
Timelines, follows, fan-out - the read-heavy classics.
- Social news feed - fan-out on write or on read
- Media feed - the feed serves URLs, the edge serves bytes
- The professional graph - degrees, and why it is not a join
- Comment trees - one range scan, and four writes per vote
- The social graph - one edge, written twice
- Home timeline - materialise it, then keep it honest
- Blog platform - write once, cache everywhere
- Link previews - fetching a stranger's page safely
- Content moderation - deciding before everyone sees it
- Stories - posts that delete themselves in 24 hours