Bird
0
0

You want to design a scalable rating and review system for millions of products and users. Which approach best balances fast average rating queries and frequent review updates?

hard📝 Trade-off Q15 of 15
LLD - Design — Food Delivery System
You want to design a scalable rating and review system for millions of products and users. Which approach best balances fast average rating queries and frequent review updates?
AStore all reviews and compute average on each query
BUse a single database table without indexes
CCache only the latest review per product
DMaintain precomputed average and count, update incrementally on review changes
Step-by-Step Solution
Solution:
  1. Step 1: Consider query and update load

    Millions of products and users mean many queries and updates.
  2. Step 2: Choose efficient strategy

    Precomputing average and count and updating them incrementally avoids scanning all reviews each time.
  3. Step 3: Evaluate other options

    Computing average on each query is slow; no indexes cause slow lookups; caching only latest review misses full rating info.
  4. Final Answer:

    Maintain precomputed average and count, update incrementally on review changes -> Option D
  5. Quick Check:

    Precompute + incremental update = scalable [OK]
Quick Trick: Precompute averages, update on changes for scale [OK]
Common Mistakes:
  • Recomputing averages on every query
  • Ignoring indexing and caching strategies
  • Caching incomplete data causing stale info

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes