StackOverflow Monolithic Architecture.

·

2 min read

No alt text provided for this image

StackOverflow is one of the most resource-demanding websites out there. Several questions, answers, and follow-ups make up threads. Then several threads for different topics. Take this and apply consistently and what you have is one huge resource-intensive application.

StackOverflow bucks the Microservices trend, handling 1.3 billion monthly pageviews across its 200 sites using a remarkably efficient monolithic architecture with minimal infrastructure with an average latency of 18 ms. The whole service is made up of the following components:

  • 9 Web Servers hosted on 3 data centers.

  • 1- HAP Proxy with a standby.

  • 1- Redis with its slave.

  • 1- SQL Database with Standby.

  • 3- Elastic search engine.

No alt text provided for this image

One thing that needs to be noted is "The components being Monolith means that they won't scale therefore the servers have to manage all load with the given resources".

  • Web Servers.

Uses only 9 on-prem IIS web servers.

Each server has 64 GB RAM and runs highly optimized .NET code.

Handles 450 peak requests/second per server with just 12% CPU Usage.

Code minimizes memory allocations to limit garbage collections.

  • SQL Servers.

Organized into 2 failover clusters of 2 servers each.

First cluster: 1.5 TB RAM per server.

Second cluster: 768 GB RAM per server.

About a third of the Q& A dataset resides in memory.

Each cluster handles over 10,000 peak queries/second at ~15% CPU.

  • Redis.

A single 256GB main server with a replica.

Handles 60000 peak ops/sec at 2% CPU.

Some features that make StackOverflow's system robust:

  • Ensuring Availability with features such as Multiple servers hosted over distributed data centers, and database with Hot Standby.

  • Ensuring performance with features such as Load balancing through HAProxies, Caching with Redis, and Quick search with ElasticSearch Engine.

Thank you and see you in the next.

Credits to @sahnlam on X(Formerly Twitter).