Design a Community Discussion Forum
Design a discussion site split into communities, where users post, reply in nested comment threads and vote posts and comments up or down, with listings ranked hot (newer posts with more votes first), new and top, and a data model and partitioning (splitting the data across many database servers) that keep working as the site grows.
Problem statement
Design a community discussion site. For this exercise, assume users join topic communities and write posts in them, each with a title and either text or a link. They reply to posts and to other replies, in nested comment threads.
They vote each post and comment up or down, with at most one vote per user on each, which they can change or remove. Each community lists its posts as hot (newer posts with more votes first), new or top, and each user's home page mixes posts from the communities they joined.
Authors can delete their posts and comments; replies to a deleted comment still show.
Be ready to go deep on the data model, on partitioning (splitting the data across many database servers), and on how the design scales.
For this exercise, also assume private messages, chat, search, ads, image or video uploads, editing, and moderation tools are out of scope.
What to build
- Users join and leave communities, and post in them with a title and either text or a link.
- Users reply to a post or to any comment at any depth; a post page shows the reply tree with the highest-voted replies first at each level, and a deleted comment that has replies keeps its place, shown as deleted.
- Users vote each post and comment up, down or not at all; a vote is never counted twice, and an item's score is its up votes minus its down votes.
- Each community lists its posts as hot, new, or top of the day, week or all time, page by page.
- Each user's home page shows hot posts from the communities they joined, page by page.
At scale
- For this exercise, assume 50 million daily active users, 100,000 active communities, and about 1 million new posts, 10 million comments and 100 million votes a day, all kept.
- For this exercise, assume about 50,000 page reads a second at peak across listings, home pages and post pages; the largest community has 30 million members, and a user joins about 20 communities on average and at most 500.
- For this exercise, assume a busy post can collect up to 50,000 comments and up to 5,000 votes a minute.
- For this exercise, assume a new post or comment must show to its author at once and to others within a few seconds, while scores and rankings may lag by up to about a minute.