Why is the Stack Overflow website so fast?

Have you heard of term caching? It is one such powerful technology to load sites faster and Stack Overflow use it aggressively.


  1. We keep a "L1" cache (basically, HttpRuntime.Cache) of recently set/read values on a server
    • Naturally, the fastest # of bytes to send across a network is 0.
  1. We compress values* before sending them to Redis
    • Most of our cached values are strings, so even at low CPU usage we get great compression ratios.
    • We also have plenty of CPU time to spare on the web tier, especially in the New York datacenter.
    • We've gotten a little smarter and only compress things that actually get smal

Have you heard of term caching? It is one such powerful technology to load sites faster and Stack Overflow use it aggressively.


  1. We keep a "L1" cache (basically, HttpRuntime.Cache) of recently set/read values on a server
    • Naturally, the fastest # of bytes to send across a network is 0.
  1. We compress values* before sending them to Redis
    • Most of our cached values are strings, so even at low CPU usage we get great compression ratios.
    • We also have plenty of CPU time to spare on the web tier, especially in the New York datacenter.
    • We've gotten a little smarter and only compress things that actually get smaller compressed (which requires some callestenics when reading keys), and .NET 4.5's GZip implementation is a lot better.


Source:
Does Stack Overflow use caching and if so, how?

Also learn about caching from HowStuffWorks "How Caching Works".

By looking just their code I could surmise its fast because:

1. Its mostly a text base site, very limited images are used.
2. They use CDN for their static content (js/css) on a cookieless domain (http://sstatic.net/)

They could easily also be using other techniques, which is justifiable if you have huge traffic and a better funded IT department like:

1. APC Caching
2. Load Balancing

They might also be using a system similar to Cloudflare and MaxCDN.
Which we've been recently experimenting with.

The contents are texts, they need very little processing on both server or client side. Static files are hosted on CDN. Most database operations are read operations so you can readily cache contents and also it's database friendly. Today's databases can be easily tuned read heavy or write heavy scenario; problem arises when neither of read and write operations is dominant.