Practice: Design a Comment System
Comment system inspired by Disqus and Reddit threads: comments are read far more than written, hot threads are cached and served from the edge, and spam checks run in the background.
Build this system yourself on the canvas below. Add components, connect them, and run traffic simulations to see where your design holds up and where it breaks.
Functional requirements
- Show the comments for a page, newest or top first, with replies nested under their parent
- Post a comment or reply; the author sees it immediately and others see it within seconds
- Check every new comment for spam in the background and hide spam without blocking the author's post
- Let a moderator remove a comment or a user, and make the removal visible quickly
- Keep every comment durably, including after a page is deleted or archived
- Limit how fast one user can post so a bot cannot flood a thread
Non-functional requirements
- Comment list < 100ms p99 for hot threads, served from the thread cache or the edge
- A new comment is visible to other readers within 5 seconds
- Spam is hidden within 30 seconds of posting
- Handle 4K requests per second at peak, with about 90% reads and 400 new comments per second
- A busy thread must not overload the database: reads come from the cache and only misses reach the database
- 99.99% durability for comments; scale to 1B comments
- 99.9% availability for reading comments