Social & content · Intermediate
Reddit-style forum
Votes through a queue, hot-score ranking computed on write, CDN for logged-out readers.
Every part, and why it is there
Readers & voters
Most visitors are logged out and just read the front page or a thread. Logged-in users vote, comment and see personalised listings.
CDN (page cache)
Logged-out users all see the same page, so whole rendered pages can be cached at the edge for a few seconds. A link going viral from another site then mostly hits the CDN, not the servers.
Load balancer
Splits traffic between the main web app and the dedicated vote endpoint, which have very different shapes of load.
Web app (monolith)
Renders listings, threads and comment trees. It reads ready-made sorted lists rather than sorting posts itself on every request.
Memcached
Caches posts, comments, accounts and rendered fragments. Reddit leans on it heavily because the same hot thread is read millions of times.
Precomputed listings
For each subreddit and sort (hot, new, top, rising) a stored list of the top post ids with their scores. Updating a list when a vote lands is far cheaper than an ORDER BY across millions of posts on every page view.
Posts & comments (Postgres)
The system of record for posts, comments, accounts and vote totals. Reads go to replicas; writes are batched by background jobs.
Vote service
Accepts an up or down vote, records it for the user and enqueues it, then returns immediately. A popular post can take thousands of votes a second; doing that work inline would lock the same database row over and over.
Vote queue
Absorbs vote bursts and lets the processors batch many votes for the same post into one update.
Vote processors
Apply votes to scores, recompute the hot score and update every listing the post appears in. This is where ranking actually happens.
Vote-manipulation checks
Discards votes from brigades, sock-puppet accounts and bots before they affect ranking. Without it, the front page could be bought.
Asked in interviews at
- intuit
Learn more
- The Evolution of Reddit.com's Architecture (InfoQ)
- Design Reddit: System Design Mock Interview (Exponent)
- 15: Reddit Comments | Systems Design Interview Questions With Ex-Google SWE (Jordan has no life)
- Architecture overview (reddit (open-source archive))
- Redis sorted sets (Redis)