Design Quora
Q&A feeds, topic graph, ranking, and moderation at hundreds of millions of questions.
Interview tip Model Question, Answer, Topic, User. Feed = mix of topic interest + social graph + quality score. Search overlaps with distributed search patterns.
① Functional requirements
- Post question with topics
- Write/edit answers with rich text
- Upvote/downvote answers
- Follow topics and users
- Personalized home feed of questions
- Search questions and answers
② Non-functional requirements
- Feed generation p99 < 300ms
- 99.9% availability
- Moderation queue for flagged content
- Global CDN for read-heavy traffic
- Eventual consistency OK for vote counts
③ Back-of-the-envelope scale
Assumptions
- 10M DAU × 50 feed items = 500M feed cells/day precomputed
- 200 writes/sec answers peak
- Vote bursts on viral answer: 10K/sec incr
- Search: 2K QPS
④ High-level architecture
Quora Architecture
Web / mobile clients
API gateway
Q&A service
Feed service
Vote/counter service
Search index
PostgreSQL + Cassandra
Questions/answers in SQL for ACID edits. Feed candidates precomputed on write fan-out to followers. Votes via counter service.
⑤ Data flow & execution path
New answer fan-out
① Post answer→② Persist Q&A DB→③ Fan-out feed cells→④ Index search→⑤ Notify followers
Feed read: pull precomputed cells + rank on read
Topic graph expands candidate pool
Quality score decays spam answers
Async moderation ML scan
Contrast fan-out on write (followers) vs fan-in on read for home feed — pick hybrid for celebrity authors.
⑥ API & interfaces
| Endpoint / flow | Purpose | Notes |
|---|---|---|
| POST /questions | Create question | topics[] required |
| POST /answers | Post answer | question_id + body |
| GET /feed | Home feed | cursor pagination |
| POST /vote | Upvote answer | idempotent per user |
| GET /search | Search Q&A | delegates to search cluster |
⑦ Data model & storage
Question, Answer, Topic, UserTopic, Vote(user, answer), FeedCell(user, question, score, ts).
| Store | What | Why |
|---|---|---|
| PostgreSQL | Q&A content | ACID edits |
| Cassandra | Feed cells per user | Wide rows by user_id |
| Redis | Hot feeds cache | Top stories |
| Search cluster | Full-text | Questions + answers |
⑧ Deep dive — core components
Feed ranking features
Score = topic_match × author_quality × recency × social_proof (votes). Train logistic model offline; serve weighted sum online for speed.
Celebrity fan-out
User with 10M followers: skip write fan-out — merge celebrity posts at read time from celebrity bucket.
⑨ Trade-offs & alternatives
| Decision | Option A | Option B | Pick when |
|---|---|---|---|
| Feed | Fan-out write | Fan-in read | Hybrid for celebrities |
| Votes | Counter service | DB row | Counter service for hot answers |
| Content | SQL | NoSQL | SQL for editable rich text |
| Moderation | Sync block | Async queue | Async ML + human review queue |
⑩ 45-minute interview script
- 0–5 min: Q&A + feed requirements
- 5–12 min: Scale and DAU math
- 12–22 min: Services diagram
- 22–32 min: Feed fan-out + ranking
- 32–40 min: Search + moderation
⑪ Likely follow-up questions
| Question | Short answer |
|---|---|
| Duplicate questions merge? | Detect similar titles via embedding similarity; moderator merges canonical question |
| Anonymous posting? | Pseudonymous user_id; still rate limit; reduced trust weight in ranking |
| Multi-language? | Language detect on post; separate search indices or multilingual embeddings |
⑫ Revision checklist
- Q&A data model
- Topic graph
- Feed precomputation
- Celebrity hybrid fan-out
- Vote counter service
- Search indexing
- Moderation pipeline
- CDN for static assets