System design · Question search, votes and ranked answers
How to design a Q&A site like Quora
Separate question identity, answers, votes and moderation state, and make ranked-answer pagination stable as votes change. This hypothetical design makes no claim about Quora's internal systems.
Updated · 4 min read
A teaching design of a system like Quora, not Quora's real architecture.
The short version
- Keep questions, answers, votes, topic links and moderation state as separate records.
- A vote is keyed by user and target, so a unique constraint stops double voting and retries replace the vote.
- Page ranked answers with a cursor tied to a ranking snapshot, never page numbers, because votes reorder the list.
- Search and ranking catch up from an outbox and can lag. Check current moderation at read time.
- Cache popular question pages, but never a user's private vote state in a shared response.
Clarifying questions to ask first
- Public knowledge base or private community? (Assume public questions with account-controlled authorship and moderation.)
- Can a question have many answers? (Assume yes, and answer ordering is a main read path.)
- How fresh must votes and ranking be? (Assume totals update quickly, while ranking and search may lag.)
- Can users follow topics and writers? (Assume topic follows and notifications, but no private messaging.)
- How do duplicate questions work? (Assume moderators merge them, keeping redirects and contribution history.)
Numbers that shape the design
These are illustrative assumptions, not Quora traffic. One million monthly users opening 100 question pages a month is 100 million / 2,592,000 seconds, about 39 reads/s, or 390/s at an assumed 10x peak. At 100 reads per write, that's about four writes/s. A page of one question and 20 answer summaries at 1 KB each is 21 KB, so about 8.2 MB/s before images and cache hits. If 10% of reads hit one question, that key sees 39 reads/s here; real viral keys can be much higher.
This points to cached read models and careful invalidation, not a specific database or cache size.
API
POST /questions
{ title, body, topicIds }
POST /questions/{questionId}/answers
{ body }
PUT /votes/{targetType}/{targetId}
{ direction, requestId }
GET /questions/{questionId}/answers?sort=ranked&cursor=...Return question and answer versions. Never trust client-provided scores or author IDs: take identity from authentication, validate the target, rate limit, and write an auditable change.
Data model
A question has an author, canonical ID, title, body version and status. An answer belongs to one canonical question and keeps edit history. Store vote events apart from aggregate counts so replay can rebuild totals. Moderation decisions, reports and appeals live in an access-controlled audit store. Each content change writes an outbox event so search and ranking can catch up.
High-level design
The write API validates the user and stores content, version and outbox record. Search indexes approved content; ranking consumers update aggregates. The read API fetches the question and ranked answers, applies current moderation and authorisation, and returns a stable cursor. A cache holds popular pages and topic views with short, version-aware invalidation.
Answer ranking
A teaching ranking might combine net votes, recency and a quality signal. This is not a claim about Quora's ranking algorithm. Keep inputs explicit and bounded so a vote burst can't move an answer without limit, and use decay or time buckets if fresh answers need a chance. Tie the cursor to a ranking snapshot plus the last score and ID. Answer ranking stays separate from personalised topic feeds (Twitter timeline covers fan-out).
Votes, duplicates and moderation
Update aggregates in the same transaction as the active vote, or through an idempotent event consumer whose lag you expose and reconcile from vote records. Rate limit vote changes and investigate unusual patterns without assuming every burst is abuse.
Search suggests existing matches before someone asks again, but similar wording alone shouldn't merge records. A moderator merges into a canonical question with a redirect map. Moderators can remove or collapse content while keeping decision history, and user-facing deletion is separate from retention for abuse or legal review. Reports are idempotent. Title suggestions while typing are autocomplete, a separate system.
Hot questions
A viral question is a hot key and can overload a partition while the rest of the site is quiet. Put the content version and ranking snapshot in the cache key, or invalidate after writes. Coalesce misses so a burst doesn't repeat one query, and use short TTLs when ranking changes often. Votes stay on the write path. See caching strategies for stampedes.
Track queue age, indexing delay, cache hit rate, hot-key traffic and ranking update time. The paired news-feed challenge covers feed distribution, not Q&A search, answer ordering, voting or moderation.
Common traps
- Keeping only aggregate vote counts. Replay, correction and abuse investigation all need the vote records.
- Using page numbers while the list changes. Readers see repeats and skips.
- Putting private vote state into a shared cached response.
- Deleting duplicate questions and losing URLs or answer attribution.
- Treating search results as authoritative after moderation changes. Removed content comes back.
Follow-up questions interviewers ask
- "How do you stop a user voting twice?" A unique active vote per user and target, and idempotent retries.
- "Can ranking be eventually consistent?" Yes, if freshness is defined and current moderation still filters results.
- "Anonymous posting?" An abuse-policy choice. Storage must not bypass moderation or rate limits.
Frequently asked questions
How should a Q&A site rank answers?
+
Start with an explicit teaching score using a few hypothetical signals such as votes and recency, then define freshness and moderation behaviour and measure usefulness.
Should vote totals update synchronously?
+
The active vote must be reliable and deduplicated. Aggregates can lag if the product accepts that delay and can rebuild from vote records.
How should duplicate questions be merged?
+
Keep a canonical ID and redirect old URLs. Preserve answer attribution and moderation history.
Does this describe Quora's internal systems?
+
No. This is a hypothetical design for a Q&A product and makes no claim about Quora's architecture, traffic or ranking.