A look at how Reddit works. Reddit is one of the most-visited sites on the internet running on a stack most modern engineers would call heresy: Python monoliths, Postgres, Varnish, and a 90%+ edge-cache hit rate that means most requests never touch an application server at all. The architecture is a love letter to caching done right.

How Reddit Works: The problem at scale
Reddit is unusual among social platforms in that the vast majority of its traffic is logged-out readers, not logged-in users. Most visitors to /r/programming or /r/worldnews never sign in. They’re there for the content, and they leave. That single fact shapes the entire architecture: a small number of write-heavy users (posters, commenters, voters) generate the content; a massive number of read-heavy users (lurkers, search visitors, embed viewers) consume it. The ratio is roughly 100:1 read-to-write. Most architectures optimize for the wrong side.
The core architecture
Requests hit Varnish edge cache first, keyed by URL. A logged-out page request for a subreddit’s front page is fully cacheable (same HTML for every anonymous visitor) and Varnish serves it directly without touching the app. On cache miss, the request flows to the Python app server (a Django-style monolith), which queries Postgres sharded by subreddit via Citus, plus a Redis layer for hot pages and vote counts. Writes (upvotes, comments, new posts) go through a Kafka queue asynchronously. The listing page you see may be a few seconds stale, which is fine because Reddit’s content doesn’t need second-level freshness.
Varnish is the architecture, not the cache
Most teams treat their CDN as infrastructure: set it and forget it. Reddit treats Varnish as a first-class architectural component, with cache invalidation logic wired into the app. When a post hits the front page, the app knows to purge the relevant cache keys so the next reader sees the update. The cache hit ratio of 90%+ isn’t a Varnish default; it’s the result of a decade of tuning what’s cacheable, for how long, and how it gets invalidated. The Python app servers would melt instantly without Varnish absorbing 90% of traffic upstream.
Async writes are why the site feels alive
Reddit processes millions of votes and comments per day. If each one synchronously updated every cached listing, the write path would saturate. Instead, votes and comments go to a Kafka queue; worker processes update Postgres, Redis, and the search index in the background; cache invalidation happens on a delay. When you upvote a comment, your UI reflects it instantly (optimistic local update), but other readers may not see your vote for 5-30 seconds. That window is the entire economic premise of the architecture: writes are cheap because they’re async, reads are cheap because they’re cached, and the brief staleness is invisible to users.
The one non-obvious insight
Reddit’s hot-ranking algorithm (the formula that decides what appears at the top of any listing) is publicly known (it’s open-source in their old repo). The formula is a function of upvotes, downvotes, submission time, and a logarithmic score that prevents early votes from dominating. The interesting part isn’t the math; it’s that the rank is computed once and cached, not recomputed per request. Every cached page already has the ranking baked in. When a post’s votes change enough to matter, the worker invalidates just that post’s listings and recomputes. The page you load is always a snapshot, never a live computation. Without this, the front page would require re-ranking 25,000 subreddits’ worth of posts on every page load.
Reddit is the proof that an old-school stack (Python monolith, Postgres, Varnish, Kafka) outperforms most microservice architectures when the cache layer is treated as the primary architectural surface. The 90%+ cache hit rate is the moat.
Continue learning: