Design: Scalable Product Reviews with Voting and Rewards
Context
You are designing a reviews feature for a large e-commerce marketplace. Customers can post reviews on products. Other customers can upvote or downvote reviews to signal helpfulness. Review authors receive rewards tied to upvote counts. The system must scale to millions of products and heavy read/write traffic, remain reliable, and resist abuse.
Requirements
-
Functional
-
Create, edit, soft-delete reviews; star ratings included.
-
Upvote/downvote reviews; support undo and changing votes.
-
Query top reviews per product, with pagination and filters (e.g., recent, top, verified purchases).
-
Claim rewards when a review’s upvotes cross thresholds.
-
Non-functional
-
High read throughput (top reviews on product pages), low latency.
-
Idempotent voting and reward claiming; prevent double-votes.
-
Abuse resistance (sybil accounts, brigading, spam).
-
Scalable counters for upvotes/downvotes (sharded or approximate) and robust ranking.
-
Caching, consistency, reliability (failover, retries, deduplication).
-
Monitoring, alerting, and backfill/repair processes.
Deliverables
-
APIs for: create review, vote/undo/change, query top reviews, claim rewards.
-
Data models for reviews, votes, counter shards/aggregates.
-
Idempotent voting design with double-vote prevention and undo/change handling.
-
Counter architecture (e.g., sharded counters or approximate) and ranking strategy.
-
Scaling, caching, consistency, reliability plan (failover, retries, dedup).
-
Monitoring, metrics, and backfill/repair processes.