HLDArena
HLD-222·Caching & Consistency
Medium · 1,000 pts

Reddit-Style Nested Comment Tree & Hot-Rank Votes

Design a threaded discussion and upvote/downvote backend serving materialized comment trees on frontpage AMA threads while coalescing vote bursts.

Max p99
≤ 58 ms
Availability
≥ 99.5%
Budget
≤ $5,500

Functional Requirements

  • FR-1GET /threads/{thread_id}/comments?sort=top — Fetches ranked nested comment subtree.
  • FR-2POST /threads/{thread_id}/comments — Appends reply or vote delta and updates materialized tree.
  • FR-3PATCH & DELETE /threads/{thread_id}/comments — Updates, cancels, or deletes thread_id records and immediately invalidates or updates cached state (read-after-write).
  • FR-4Comment authors must see their posted reply immediately (read-after-write) and survive storage brownouts.

Workload Profile

Baseline Subreddits34,000 Read RPS / 5,000 Comment & Vote Write RPS
Frontpage AMA Surge98,000 Read RPS / 15,000 Write RPS
Active Working Set26 GB hot frontpage comment trees
Traffic DistributionExtreme Zipfian skew on top 50 frontpage thread_id posts

Consistency Model

Read-after-write consistency for newly submitted comments; vote tallies eventually converge within 2s.

Design Write-up
0 boxes · 0 edges
0 words
Hidden Cases #4–#7 run automatically on Submit
Case 1: Smoke & API ContractInput Workload
Read RPS
2,000 rps
Write RPS
400 rps
Key Distribution
Uniform (Low Skew)
Chaos Fault
None (Healthy Cluster)
Expected Pass CriteriaASSERTIONS
• Tail Latency: p99 ≤ 116 ms
• Availability: ≥ 99.5%
Valid end-to-end Client → Compute → Storage topology