Design a Real-Time Commenting System

System Design
Medium
Meta
131.2K views

Design the backend for a high-volume, low-latency commenting service for articles/videos. Focus on read/write separation and real-time updates.

Why Interviewers Ask This

Meta interviewers ask this to evaluate your ability to balance high read-throughput with low-latency writes in a globally distributed environment. They specifically test if you can design for real-time consistency using caching layers and pub/sub mechanisms while handling write amplification common in social feeds.

How to Answer This Question

1. Clarify requirements: Define scale (e.g., millions of daily active users), latency targets (sub-200ms reads), and consistency models (eventual vs. strong). 2. Outline the high-level architecture: Propose a read-heavy model where comments are cached aggressively, separating write paths from read paths. 3. Detail the write flow: Explain how to ingest comments via an API gateway, validate them, and push them to a message queue like Kafka or Pulsar for async processing. 4. Design the read path: Describe using Redis or Memcached as a hot cache layer, fetching data from a primary database only on misses, and utilizing fan-out-on-read or fan-out-on-write strategies depending on author popularity. 5. Address real-time updates: Integrate WebSocket connections or Server-Sent Events to push new comments instantly to subscribers without polling. 6. Discuss scalability: Mention sharding strategies for the database and partitioning topics by article ID to handle uneven traffic distribution.

Key Points to Cover

  • Explicitly defining the read/write ratio to justify the chosen architecture
  • Demonstrating knowledge of asynchronous processing via message queues like Kafka
  • Proposing a specific caching strategy (Redis) with clear invalidation logic
  • Explaining the mechanism for real-time delivery using WebSockets or similar protocols
  • Addressing data partitioning strategies to handle hot partitions for popular articles

Sample Answer

To design a real-time commenting system for Meta-scale traffic, I would prioritize read performance since users consume far more content than they create. First, I'd define the API contract to support pagination and sort…

Common Mistakes to Avoid

  • Focusing solely on database schema without addressing the high-volume read bottleneck
  • Ignoring the need for a message queue and attempting synchronous database writes for every request
  • Overlooking how to handle 'hot' articles that generate massive write contention
  • Forgetting to explain how real-time updates reach the client without constant polling

Sound confident on this question in 5 minutes

Answer once and get a 30-second AI critique of your structure, content, and delivery. First attempt is free — no signup needed.

Try it free

Related Interview Questions

Browse all 190 System Design questionsBrowse all 71 Meta questions