Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Stack Overflow has implemented caching?

Not sure if Stack Overflow uses caching to enhance the loading speed of its pages, but if it has, it has done a great job. There are many components to be updated. I this picture you see every single second there are many components to be updated. How Stack Overflow does it so perfectly?enter image description here

like image 246
C graphics Avatar asked Feb 28 '16 04:02

C graphics


1 Answers

This is answered much more comprehensively on Meta.SE in this answer. The highlights, however, are:

  • Basically everything is cached, especially everything served to anonymous users.
  • They use Redis servers with 96 GB of Ram. This server keeps an "L1 Cache" of recently set and read values. These values are compressed before sending them to Redis. They also use IIS's Output Caching
  • Each site has 3 types of caches:
    • "Local" (user sessions, view counts, etc)
    • "Site" (hot question ids, user acceptance rates)
    • "Global" (user inboxes, API quotas)

There are even more details on High Scalability , though this is nearly 5 years old at this point. There is a newer article (from 2014) that mentions that there are two additional levels of caching involved as well:

  • SQL Server (the entire database sits in memory). As of 2013, the database servers had 384 GB of memory
  • SSD (hit only when the SQL server cache is warming up...as not something I'd consider "cache", but it's mentioned in the article).
like image 169
Andy Avatar answered Oct 08 '22 05:10

Andy