SlideShare uma empresa Scribd logo
1 de 32
Software architecture for high
traffic website
Case study - Stack Overflow
Presenter: Ngô Xuân Hòa (Novaon Adnetwork - Novanet)
Hanoi .Net Meetup
Contents
About Stack Overflow
● Beginning
● Restructure #1
● Restructure # 2
● Founders
● Principles
SO architecture
● StackExchange.Redis
● Dapper
● Jil
Open-source Libs
About Stack Overflow
Founders
Jeff Atwood
Joel Spolsky
2008
Stack Overflow
2009 2010 2011
Server Fault
Stack Exchange 1.0
Stack Exchange 2.0
Stack Overflow Carees
Rome wasn’t build in a day!
● 100+ Q&A Sites
● 600+ million pageviews a month
● 3000+ requests per second
● 16+ million users
● 8+ million question
● 40+ million answers
Principles
Perfomance Is a Feature
Cache All The Thing!
Reinvention is OK
Stack Overflow Architecture
2 times restructuring
Stack Exchange 1.0
● ASP.NET MVC
● SQL Server
● LINQ to SQL
● Wikipedia DB
Design
Stack Exchange Network
LINQ to SQL
HAProxy
Redis
Lucene.NET
Scale Up
● Cache every things
● Elastic Search
● Reinvention
Stack Exchange 1.0 Structure
Windows NLBLoad balancing
IIS Server IIS ServerWeb server
SQL ServerDatabase
Window NLB
● Cons:
○ Limit to 8
Nodes
○ Cannot detect
service failed
Web-tier
ASP.NET MVC
LINQ to SQL
SQL Server
● All-in-memory
● Full text search
● 16 million pageviews a month
● 3 million unique visitors a month
● 6 million visits a month
Follow none but learn from everyone!
Pros
● Bottleneck: Database SQL Server
● High cost to scale up
● Simple
Cons
Restructure #1 - Stack Exchange Network
HAProxy
Redis Cache
Lucene.NET
Tag Engine
Stack Exchange Network Structure
HAProxy
Redis
IIS Servers
Database
protobuf
sqlhttp http
Load Balancing
● HAProxy:
○ Run in Linux
○ Free
Web-tier
ASP.NET MVC 3
LINQ to SQL
jQuery 1.4.5
Lucene.Net
Redis
● In-memory cache
● Master-slave
● Messaging notification
3 Type Cache
Local Cache Site Cache
● Use Redis
● Cache Site’s data:
- Q&As
- Acceptance rates
- ...
Global Cache
● Use Redis
● Cache System Data:
- User info
- Inbox
- ...
● Use
HttpRunTime.Cache
● Cache:
- User Session
- View Count
- ...
Update cache flow - Local cache
Local Cache
Redis
DB
Other sites
1 3
2.1
2.2
4
1 - OnStartup - Subcribe invalidation message
to Redis
2.1 - Data changed (by other sites, apps…)
2.2 - Send message to Redis
3 - Redis send Notification to Subscribers
4 - Get data from DB - update Local cache
Deployment flow with HAProxy
● Tell HAProxy to take the server out of rotation via a POST
● Delay to let IIS finish current requests (~5 sec)
● Stop the website
● Copy files
● Start the website
● Local testing, update local cache, etc…
● Re-enable HAProxy via another POST
● High performance
● Low-cost Load Balancing
(use HAProxy)
● Use Messaging của Redis
for cache invalidation
Pros
● Too many SQL query
Cons
● 95 million pageviews a month
● 800 requests per second
● 16 million users
Restructure #2 - Scale Up
Cache All the Thing
Elastic Search
Reinvention
Stack Exchange Network Structure
Elastic Search
Tag Engine
Databases
Redis
HAProxy
5 Level cache
Network Level Local Cache Redis Cache SQL SV Cache SSD
● Network Level: Browser cache…
● Local Cache: HttpRuntime.Cache - Cache all data in memory
● Redis Cache: Cache all data
● SQL Server Cache: Cache all data in memory (the database servers have 384GB of RAM)
Cache Flow
● Check Local Cache
● Else, check Redis Cache and update Local Cache
● If Cache Redis doesn’t have data, fetch from databases, then update Redis Cache
and Local Cache
Cache All the Things!
Pros
● Data has latency
● Very, Very Fast (<400ms)
● Low servers load:
○ IIS: 10-15% CPU usage
○ DB: 10% CPU usage
● 99% request served by cache
Cons
● 95 million pageviews a month
● 800 requests per second
● 16 million users
Open-source Libs
• StackExchange.Redis - high perfomance Redis client
• Dapper - a micro ORM - very fast
• Jil - fast JSON Serializer
Reinvention is OK!
Reference sources
● http://stackoverflow.com
● http://highscalability.com
● http://codinghorror.com
● http://www.joelonsoftware.com
● http://nickcraver.com
● http://josephwoodward.co.uk/2014/02/the-architecture-of-stackoverflow/
Thank you!
Ngô Xuân Hòa
xuanhoa862001@gmail.com

Mais conteúdo relacionado

Mais procurados

Tiki.vn - How we scale as a tech startup
Tiki.vn - How we scale as a tech startupTiki.vn - How we scale as a tech startup
Tiki.vn - How we scale as a tech startupTung Ns
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetesRishabh Indoria
 
Toi uu hoa he thong 30 trieu nguoi dung
Toi uu hoa he thong 30 trieu nguoi dungToi uu hoa he thong 30 trieu nguoi dung
Toi uu hoa he thong 30 trieu nguoi dungIT Expert Club
 
Grokking TechTalk #33: High Concurrency Architecture at TIKI
Grokking TechTalk #33: High Concurrency Architecture at TIKIGrokking TechTalk #33: High Concurrency Architecture at TIKI
Grokking TechTalk #33: High Concurrency Architecture at TIKIGrokking VN
 
Kubernetes #2 monitoring
Kubernetes #2   monitoring Kubernetes #2   monitoring
Kubernetes #2 monitoring Terry Cho
 
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹InfraEngineer
 
NGINX Ingress Controller for Kubernetes
NGINX Ingress Controller for KubernetesNGINX Ingress Controller for Kubernetes
NGINX Ingress Controller for KubernetesNGINX, Inc.
 
Opentelemetry - From frontend to backend
Opentelemetry - From frontend to backendOpentelemetry - From frontend to backend
Opentelemetry - From frontend to backendSebastian Poxhofer
 
Getting Started with Kubernetes
Getting Started with Kubernetes Getting Started with Kubernetes
Getting Started with Kubernetes VMware Tanzu
 
Domain Driven Design và Event Driven Architecture
Domain Driven Design và Event Driven Architecture Domain Driven Design và Event Driven Architecture
Domain Driven Design và Event Driven Architecture IT Expert Club
 
Docker swarm introduction
Docker swarm introductionDocker swarm introduction
Docker swarm introductionEvan Lin
 
AWS DevOps - Terraform, Docker, HashiCorp Vault
AWS DevOps - Terraform, Docker, HashiCorp VaultAWS DevOps - Terraform, Docker, HashiCorp Vault
AWS DevOps - Terraform, Docker, HashiCorp VaultGrzegorz Adamowicz
 
kubernetes - minikube - getting started
kubernetes - minikube - getting startedkubernetes - minikube - getting started
kubernetes - minikube - getting startedMunish Mehta
 
High Concurrency Architecture at TIKI
High Concurrency Architecture at TIKIHigh Concurrency Architecture at TIKI
High Concurrency Architecture at TIKINghia Minh
 
Extending kubernetes with CustomResourceDefinitions
Extending kubernetes with CustomResourceDefinitionsExtending kubernetes with CustomResourceDefinitions
Extending kubernetes with CustomResourceDefinitionsStefan Schimanski
 
A year with event sourcing and CQRS
A year with event sourcing and CQRSA year with event sourcing and CQRS
A year with event sourcing and CQRSSteve Pember
 
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?OpenStack Korea Community
 
Prometheus
PrometheusPrometheus
Prometheuswyukawa
 
Using the New Apache Flink Kubernetes Operator in a Production Deployment
Using the New Apache Flink Kubernetes Operator in a Production DeploymentUsing the New Apache Flink Kubernetes Operator in a Production Deployment
Using the New Apache Flink Kubernetes Operator in a Production DeploymentFlink Forward
 

Mais procurados (20)

Tiki.vn - How we scale as a tech startup
Tiki.vn - How we scale as a tech startupTiki.vn - How we scale as a tech startup
Tiki.vn - How we scale as a tech startup
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
Toi uu hoa he thong 30 trieu nguoi dung
Toi uu hoa he thong 30 trieu nguoi dungToi uu hoa he thong 30 trieu nguoi dung
Toi uu hoa he thong 30 trieu nguoi dung
 
Grokking TechTalk #33: High Concurrency Architecture at TIKI
Grokking TechTalk #33: High Concurrency Architecture at TIKIGrokking TechTalk #33: High Concurrency Architecture at TIKI
Grokking TechTalk #33: High Concurrency Architecture at TIKI
 
Kubernetes #2 monitoring
Kubernetes #2   monitoring Kubernetes #2   monitoring
Kubernetes #2 monitoring
 
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹
[MeetUp][1st] 오리뎅이의_쿠버네티스_네트워킹
 
kubernetes, pourquoi et comment
kubernetes, pourquoi et commentkubernetes, pourquoi et comment
kubernetes, pourquoi et comment
 
NGINX Ingress Controller for Kubernetes
NGINX Ingress Controller for KubernetesNGINX Ingress Controller for Kubernetes
NGINX Ingress Controller for Kubernetes
 
Opentelemetry - From frontend to backend
Opentelemetry - From frontend to backendOpentelemetry - From frontend to backend
Opentelemetry - From frontend to backend
 
Getting Started with Kubernetes
Getting Started with Kubernetes Getting Started with Kubernetes
Getting Started with Kubernetes
 
Domain Driven Design và Event Driven Architecture
Domain Driven Design và Event Driven Architecture Domain Driven Design và Event Driven Architecture
Domain Driven Design và Event Driven Architecture
 
Docker swarm introduction
Docker swarm introductionDocker swarm introduction
Docker swarm introduction
 
AWS DevOps - Terraform, Docker, HashiCorp Vault
AWS DevOps - Terraform, Docker, HashiCorp VaultAWS DevOps - Terraform, Docker, HashiCorp Vault
AWS DevOps - Terraform, Docker, HashiCorp Vault
 
kubernetes - minikube - getting started
kubernetes - minikube - getting startedkubernetes - minikube - getting started
kubernetes - minikube - getting started
 
High Concurrency Architecture at TIKI
High Concurrency Architecture at TIKIHigh Concurrency Architecture at TIKI
High Concurrency Architecture at TIKI
 
Extending kubernetes with CustomResourceDefinitions
Extending kubernetes with CustomResourceDefinitionsExtending kubernetes with CustomResourceDefinitions
Extending kubernetes with CustomResourceDefinitions
 
A year with event sourcing and CQRS
A year with event sourcing and CQRSA year with event sourcing and CQRS
A year with event sourcing and CQRS
 
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
 
Prometheus
PrometheusPrometheus
Prometheus
 
Using the New Apache Flink Kubernetes Operator in a Production Deployment
Using the New Apache Flink Kubernetes Operator in a Production DeploymentUsing the New Apache Flink Kubernetes Operator in a Production Deployment
Using the New Apache Flink Kubernetes Operator in a Production Deployment
 

Semelhante a Software architecture for high traffic website

SharePoint Saturday San Antonio: SharePoint 2010 Performance
SharePoint Saturday San Antonio: SharePoint 2010 PerformanceSharePoint Saturday San Antonio: SharePoint 2010 Performance
SharePoint Saturday San Antonio: SharePoint 2010 PerformanceBrian Culver
 
SharePoint Saturday The Conference 2011 - SP2010 Performance
SharePoint Saturday The Conference 2011 - SP2010 PerformanceSharePoint Saturday The Conference 2011 - SP2010 Performance
SharePoint Saturday The Conference 2011 - SP2010 PerformanceBrian Culver
 
GlobalsDB: Its significance for Node.js Developers
GlobalsDB: Its significance for Node.js DevelopersGlobalsDB: Its significance for Node.js Developers
GlobalsDB: Its significance for Node.js DevelopersRob Tweed
 
Stack Exchange Infrastructure - LISA 14
Stack Exchange Infrastructure - LISA 14Stack Exchange Infrastructure - LISA 14
Stack Exchange Infrastructure - LISA 14GABeech
 
Stack Exchange Infrastructure - LISA 14
Stack Exchange Infrastructure - LISA 14Stack Exchange Infrastructure - LISA 14
Stack Exchange Infrastructure - LISA 14GABeech
 
SharePoint 2010 Boost your farm performance!
SharePoint 2010 Boost your farm performance!SharePoint 2010 Boost your farm performance!
SharePoint 2010 Boost your farm performance!Brian Culver
 
JavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User ExperienceJavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User Experiencereeder29
 
Tuning Your SharePoint Environment
Tuning Your SharePoint EnvironmentTuning Your SharePoint Environment
Tuning Your SharePoint Environmentvmaximiuk
 
Mongo db admin_20110329
Mongo db admin_20110329Mongo db admin_20110329
Mongo db admin_20110329radiocats
 
Blackray @ SAPO CodeBits 2009
Blackray @ SAPO CodeBits 2009Blackray @ SAPO CodeBits 2009
Blackray @ SAPO CodeBits 2009fschupp
 
RESTful web
RESTful webRESTful web
RESTful webAlvin Qi
 
BlackRay - The open Source Data Engine
BlackRay - The open Source Data EngineBlackRay - The open Source Data Engine
BlackRay - The open Source Data Enginefschupp
 
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...Restlet
 
Restlet: Building a multi-tenant API PaaS with DataStax Enterprise Search
Restlet: Building a multi-tenant API PaaS with DataStax Enterprise SearchRestlet: Building a multi-tenant API PaaS with DataStax Enterprise Search
Restlet: Building a multi-tenant API PaaS with DataStax Enterprise SearchDataStax Academy
 
05.m3 cms list-ofwebserver
05.m3 cms list-ofwebserver05.m3 cms list-ofwebserver
05.m3 cms list-ofwebservertarensi
 
Web Servers(IIS, NGINX, APACHE)
Web Servers(IIS, NGINX, APACHE)Web Servers(IIS, NGINX, APACHE)
Web Servers(IIS, NGINX, APACHE)Reza Jebeli
 
Scaling WordPress - Project Lana WordPress Team
Scaling WordPress - Project Lana WordPress TeamScaling WordPress - Project Lana WordPress Team
Scaling WordPress - Project Lana WordPress TeamDat Hoang
 
A Day in the Life of a Druid Implementor and Druid's Roadmap
A Day in the Life of a Druid Implementor and Druid's RoadmapA Day in the Life of a Druid Implementor and Druid's Roadmap
A Day in the Life of a Druid Implementor and Druid's RoadmapItai Yaffe
 

Semelhante a Software architecture for high traffic website (20)

SharePoint Saturday San Antonio: SharePoint 2010 Performance
SharePoint Saturday San Antonio: SharePoint 2010 PerformanceSharePoint Saturday San Antonio: SharePoint 2010 Performance
SharePoint Saturday San Antonio: SharePoint 2010 Performance
 
SharePoint Saturday The Conference 2011 - SP2010 Performance
SharePoint Saturday The Conference 2011 - SP2010 PerformanceSharePoint Saturday The Conference 2011 - SP2010 Performance
SharePoint Saturday The Conference 2011 - SP2010 Performance
 
GlobalsDB: Its significance for Node.js Developers
GlobalsDB: Its significance for Node.js DevelopersGlobalsDB: Its significance for Node.js Developers
GlobalsDB: Its significance for Node.js Developers
 
Stack Exchange Infrastructure - LISA 14
Stack Exchange Infrastructure - LISA 14Stack Exchange Infrastructure - LISA 14
Stack Exchange Infrastructure - LISA 14
 
Stack Exchange Infrastructure - LISA 14
Stack Exchange Infrastructure - LISA 14Stack Exchange Infrastructure - LISA 14
Stack Exchange Infrastructure - LISA 14
 
Sharepoint Deployments
Sharepoint DeploymentsSharepoint Deployments
Sharepoint Deployments
 
SharePoint 2010 Boost your farm performance!
SharePoint 2010 Boost your farm performance!SharePoint 2010 Boost your farm performance!
SharePoint 2010 Boost your farm performance!
 
JavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User ExperienceJavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User Experience
 
Tuning Your SharePoint Environment
Tuning Your SharePoint EnvironmentTuning Your SharePoint Environment
Tuning Your SharePoint Environment
 
Mongo db admin_20110329
Mongo db admin_20110329Mongo db admin_20110329
Mongo db admin_20110329
 
Blackray @ SAPO CodeBits 2009
Blackray @ SAPO CodeBits 2009Blackray @ SAPO CodeBits 2009
Blackray @ SAPO CodeBits 2009
 
RESTful web
RESTful webRESTful web
RESTful web
 
NoSQL
NoSQLNoSQL
NoSQL
 
BlackRay - The open Source Data Engine
BlackRay - The open Source Data EngineBlackRay - The open Source Data Engine
BlackRay - The open Source Data Engine
 
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
 
Restlet: Building a multi-tenant API PaaS with DataStax Enterprise Search
Restlet: Building a multi-tenant API PaaS with DataStax Enterprise SearchRestlet: Building a multi-tenant API PaaS with DataStax Enterprise Search
Restlet: Building a multi-tenant API PaaS with DataStax Enterprise Search
 
05.m3 cms list-ofwebserver
05.m3 cms list-ofwebserver05.m3 cms list-ofwebserver
05.m3 cms list-ofwebserver
 
Web Servers(IIS, NGINX, APACHE)
Web Servers(IIS, NGINX, APACHE)Web Servers(IIS, NGINX, APACHE)
Web Servers(IIS, NGINX, APACHE)
 
Scaling WordPress - Project Lana WordPress Team
Scaling WordPress - Project Lana WordPress TeamScaling WordPress - Project Lana WordPress Team
Scaling WordPress - Project Lana WordPress Team
 
A Day in the Life of a Druid Implementor and Druid's Roadmap
A Day in the Life of a Druid Implementor and Druid's RoadmapA Day in the Life of a Druid Implementor and Druid's Roadmap
A Day in the Life of a Druid Implementor and Druid's Roadmap
 

Mais de Tung Nguyen Thanh

How to become senior .net developer
How to become senior .net developerHow to become senior .net developer
How to become senior .net developerTung Nguyen Thanh
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design IntroductionTung Nguyen Thanh
 
Continuous Delivery with VS2015 and TFS2015
Continuous Delivery with VS2015 and TFS2015Continuous Delivery with VS2015 and TFS2015
Continuous Delivery with VS2015 and TFS2015Tung Nguyen Thanh
 
Agile .NET Development with BDD and Continuous Integration
Agile .NET Development with BDD and Continuous IntegrationAgile .NET Development with BDD and Continuous Integration
Agile .NET Development with BDD and Continuous IntegrationTung Nguyen Thanh
 
Performance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL DatabasePerformance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL DatabaseTung Nguyen Thanh
 
HaNoi Net Group Introduction
HaNoi Net Group IntroductionHaNoi Net Group Introduction
HaNoi Net Group IntroductionTung Nguyen Thanh
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven DevelopmentTung Nguyen Thanh
 
Visual studio 2015 ide new features
Visual studio 2015 ide new featuresVisual studio 2015 ide new features
Visual studio 2015 ide new featuresTung Nguyen Thanh
 
How to release every week case study of continuous integration
How to release every week case study of continuous integrationHow to release every week case study of continuous integration
How to release every week case study of continuous integrationTung Nguyen Thanh
 
Workshop fight legacy code write unit test
Workshop fight legacy code write unit testWorkshop fight legacy code write unit test
Workshop fight legacy code write unit testTung Nguyen Thanh
 
Developing windows phone 7 application with silverlight
Developing windows phone 7 application with silverlightDeveloping windows phone 7 application with silverlight
Developing windows phone 7 application with silverlightTung Nguyen Thanh
 
Top 100 .NET Interview Questions and Answers
Top 100 .NET Interview Questions and AnswersTop 100 .NET Interview Questions and Answers
Top 100 .NET Interview Questions and AnswersTung Nguyen Thanh
 
New in Visual Studio and TFS 2013
New in Visual Studio and TFS 2013New in Visual Studio and TFS 2013
New in Visual Studio and TFS 2013Tung Nguyen Thanh
 

Mais de Tung Nguyen Thanh (20)

How to become senior .net developer
How to become senior .net developerHow to become senior .net developer
How to become senior .net developer
 
Docker for .net developer
Docker for .net developerDocker for .net developer
Docker for .net developer
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
SignalR with ASP.NET MVC 6
SignalR with ASP.NET MVC 6SignalR with ASP.NET MVC 6
SignalR with ASP.NET MVC 6
 
Continuous Delivery with VS2015 and TFS2015
Continuous Delivery with VS2015 and TFS2015Continuous Delivery with VS2015 and TFS2015
Continuous Delivery with VS2015 and TFS2015
 
Agile .NET Development with BDD and Continuous Integration
Agile .NET Development with BDD and Continuous IntegrationAgile .NET Development with BDD and Continuous Integration
Agile .NET Development with BDD and Continuous Integration
 
Performance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL DatabasePerformance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL Database
 
HaNoi Net Group Introduction
HaNoi Net Group IntroductionHaNoi Net Group Introduction
HaNoi Net Group Introduction
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven Development
 
Refactoring code in .net
Refactoring code in .netRefactoring code in .net
Refactoring code in .net
 
Visual studio 2015 ide new features
Visual studio 2015 ide new featuresVisual studio 2015 ide new features
Visual studio 2015 ide new features
 
Whatmakesoftwareflexible
WhatmakesoftwareflexibleWhatmakesoftwareflexible
Whatmakesoftwareflexible
 
How to release every week case study of continuous integration
How to release every week case study of continuous integrationHow to release every week case study of continuous integration
How to release every week case study of continuous integration
 
Xp not windows xp
Xp not windows xpXp not windows xp
Xp not windows xp
 
Is xp still extreme
Is xp still extremeIs xp still extreme
Is xp still extreme
 
Workshop fight legacy code write unit test
Workshop fight legacy code write unit testWorkshop fight legacy code write unit test
Workshop fight legacy code write unit test
 
Windows Phone Introduction
Windows Phone IntroductionWindows Phone Introduction
Windows Phone Introduction
 
Developing windows phone 7 application with silverlight
Developing windows phone 7 application with silverlightDeveloping windows phone 7 application with silverlight
Developing windows phone 7 application with silverlight
 
Top 100 .NET Interview Questions and Answers
Top 100 .NET Interview Questions and AnswersTop 100 .NET Interview Questions and Answers
Top 100 .NET Interview Questions and Answers
 
New in Visual Studio and TFS 2013
New in Visual Studio and TFS 2013New in Visual Studio and TFS 2013
New in Visual Studio and TFS 2013
 

Último

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Último (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Software architecture for high traffic website

  • 1. Software architecture for high traffic website Case study - Stack Overflow Presenter: Ngô Xuân Hòa (Novaon Adnetwork - Novanet) Hanoi .Net Meetup
  • 2. Contents About Stack Overflow ● Beginning ● Restructure #1 ● Restructure # 2 ● Founders ● Principles SO architecture ● StackExchange.Redis ● Dapper ● Jil Open-source Libs
  • 5. 2008 Stack Overflow 2009 2010 2011 Server Fault Stack Exchange 1.0 Stack Exchange 2.0 Stack Overflow Carees Rome wasn’t build in a day!
  • 6. ● 100+ Q&A Sites ● 600+ million pageviews a month ● 3000+ requests per second ● 16+ million users ● 8+ million question ● 40+ million answers
  • 7. Principles Perfomance Is a Feature Cache All The Thing! Reinvention is OK
  • 9. 2 times restructuring Stack Exchange 1.0 ● ASP.NET MVC ● SQL Server ● LINQ to SQL ● Wikipedia DB Design Stack Exchange Network LINQ to SQL HAProxy Redis Lucene.NET Scale Up ● Cache every things ● Elastic Search ● Reinvention
  • 10. Stack Exchange 1.0 Structure Windows NLBLoad balancing IIS Server IIS ServerWeb server SQL ServerDatabase
  • 11. Window NLB ● Cons: ○ Limit to 8 Nodes ○ Cannot detect service failed Web-tier ASP.NET MVC LINQ to SQL SQL Server ● All-in-memory ● Full text search
  • 12. ● 16 million pageviews a month ● 3 million unique visitors a month ● 6 million visits a month
  • 13. Follow none but learn from everyone!
  • 14. Pros ● Bottleneck: Database SQL Server ● High cost to scale up ● Simple Cons
  • 15. Restructure #1 - Stack Exchange Network HAProxy Redis Cache Lucene.NET Tag Engine
  • 16. Stack Exchange Network Structure HAProxy Redis IIS Servers Database protobuf sqlhttp http
  • 17. Load Balancing ● HAProxy: ○ Run in Linux ○ Free Web-tier ASP.NET MVC 3 LINQ to SQL jQuery 1.4.5 Lucene.Net Redis ● In-memory cache ● Master-slave ● Messaging notification
  • 18. 3 Type Cache Local Cache Site Cache ● Use Redis ● Cache Site’s data: - Q&As - Acceptance rates - ... Global Cache ● Use Redis ● Cache System Data: - User info - Inbox - ... ● Use HttpRunTime.Cache ● Cache: - User Session - View Count - ...
  • 19. Update cache flow - Local cache Local Cache Redis DB Other sites 1 3 2.1 2.2 4 1 - OnStartup - Subcribe invalidation message to Redis 2.1 - Data changed (by other sites, apps…) 2.2 - Send message to Redis 3 - Redis send Notification to Subscribers 4 - Get data from DB - update Local cache
  • 20. Deployment flow with HAProxy ● Tell HAProxy to take the server out of rotation via a POST ● Delay to let IIS finish current requests (~5 sec) ● Stop the website ● Copy files ● Start the website ● Local testing, update local cache, etc… ● Re-enable HAProxy via another POST
  • 21. ● High performance ● Low-cost Load Balancing (use HAProxy) ● Use Messaging của Redis for cache invalidation Pros ● Too many SQL query Cons
  • 22. ● 95 million pageviews a month ● 800 requests per second ● 16 million users
  • 23. Restructure #2 - Scale Up Cache All the Thing Elastic Search Reinvention
  • 24. Stack Exchange Network Structure Elastic Search Tag Engine Databases Redis HAProxy
  • 25. 5 Level cache Network Level Local Cache Redis Cache SQL SV Cache SSD ● Network Level: Browser cache… ● Local Cache: HttpRuntime.Cache - Cache all data in memory ● Redis Cache: Cache all data ● SQL Server Cache: Cache all data in memory (the database servers have 384GB of RAM)
  • 26. Cache Flow ● Check Local Cache ● Else, check Redis Cache and update Local Cache ● If Cache Redis doesn’t have data, fetch from databases, then update Redis Cache and Local Cache
  • 27. Cache All the Things!
  • 28. Pros ● Data has latency ● Very, Very Fast (<400ms) ● Low servers load: ○ IIS: 10-15% CPU usage ○ DB: 10% CPU usage ● 99% request served by cache Cons
  • 29. ● 95 million pageviews a month ● 800 requests per second ● 16 million users
  • 30. Open-source Libs • StackExchange.Redis - high perfomance Redis client • Dapper - a micro ORM - very fast • Jil - fast JSON Serializer Reinvention is OK!
  • 31. Reference sources ● http://stackoverflow.com ● http://highscalability.com ● http://codinghorror.com ● http://www.joelonsoftware.com ● http://nickcraver.com ● http://josephwoodward.co.uk/2014/02/the-architecture-of-stackoverflow/
  • 32. Thank you! Ngô Xuân Hòa xuanhoa862001@gmail.com