SlideShare a Scribd company logo
1 of 58
1
Scaling Stack Overflow
David Fullerton, VP Engineering • @df07
QCon NYC • 2015-06-12
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Watch the video with slide
synchronization on InfoQ.com!
http://www.infoq.com/presentations
/stack-exchange
Presented at QCon New York
www.qconnewyork.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
2
**SPOILERS**
3
Conclusions
1. Our architecture is boring
4
Conclusions
1. Our architecture is boring
1. How we keep it boring is interesting
5
What’s Stack Overflow?
6
Q&A for Programmers
• 9.4M questions
• 16M answers
• 45M uniques / month
• 8,000 new questions every day
(quantcast.com/stackoverflow.com)
7
Developer Jobs
• Best place on the internet to get a programming
job or hire a developer
8
Part of Stack Exchange Network
• Stack Overflow-style Q&A in 143 other topics &
languages
9
A Distributed Team
• 34 developers, 6 sysadmins, 6 designers
• 75% remote
10
A Distributed Team
• 34 developers, 6 sysadmins, 6 designers
• 75% remote
11
How do we work?
• Remote work culture
• Hire smart people and get out of their way
• Full-stack developers / sysadmins with a
specialty
12
Our Architecture
(I warned you, it’s boring)
13
(stackexchange.com/performance)
14
“Monolith Plus” architecture
• Almost everything happens in
the web tier + DB
• A few services pulled out and
optimized
15
Scales pretty well (for us)
• 4 billion requests per month, 3000 req/s peak
• 800M SQL queries per day, 8500/s peak
16
(opserver – https://github.com/opserver/opserver)
17
(opserver – https://github.com/opserver/opserver)
18
New York
(primary)
Oregon
(secondary)
Availability (also boring)
19
Deploys
• All day every day
• Rolling deploys through the web tier
(TeamCity)
Fast!
20
Testing
• Test on our users
• Feature flag
– Turn it on for a subset of sites to see how it
performs
21
* Works for us!
• Read-heavy load centered on one page
• Not as much customized content as some sites
• A forgiving community
22
23
How did we get here?
24
Our Process
1. Start with what we know
2. Measure it live
3. Fix the slow
25
Step 1: Start with what we know
• Original developers knew C# and MSSQL
• Started with a bunch of off-the-shelf tools:
– ASP.NET MVC
– LINQ to SQL
– MSSQL + SQL fulltext search
– Built-in caching (no Redis)
26
Step 2: Measure it live
• Performance is a feature!
• Test under real load
• Measure, don’t guess
27
(miniprofiler – https://github.com/MiniProfiler/dotnet)
28
(miniprofiler – https://github.com/MiniProfiler/dotnet)
29
(opserver – https://github.com/opserver/opserver)
30
(opserver – https://github.com/opserver/opserver)
31
Step 3: Fix the slow
• Slow performance is a bug, fix it now!
• Over time, replace major parts of our stack:
– Caching and Redis
– SQL access
– Tag Engine
– Elasticsearch
32
• Already hand-rolling queries for performance
• LINQ to SQL provides basic ORM:
Dapper
33
• Problem:
Dapper
34
• Solution: replace the object mapper
• Idea: emit raw IL, then cache mapper
Dapper
35
• Results (500 iterations):
Dapper
(dapper– https://code.google.com/p/dapper-dot-net/)
36
Tag Engine
37
Tag Engine
• Early hack: use SQL fulltext search to index tags
38
Tag Engine
• Problem:
39
Tag Engine
• Problem:
• Performance!
40
Tag Engine
• Highly custom in-memory tag index cache
• Carefully memory-managed to avoid GC stalls
– Learned the hard way: see “Assault by GC” by
Marc Gravell
• Serialize / deserialize from disk on build
41
Results
42
Results
1. Start with what we know
2. Measure it live
3. Fix the slow
Optimize for performance,
get scale thrown in
43
Results
• “Monolith Plus” architecture
• Extract services that solve real problems, not
imagined ones
• Avoid SOA “tax”
44
So my primary guideline would be don’t even
consider microservices unless you have a
system that’s too complex to manage as a
monolith
- Martin Fowler, “MicroservicePremium”
45
Conclusions
46
Conclusions
1. Our architecture is boring
2. How we keep it boring is interesting:
1. Start with what we know
2. Measure it live
3. Fix the slow
47
Application
• You can optimize for performance and get scale
thrown in (almost for free)
• Your monolith can scale further than you think
• SOA is not the only way
– Know your own problem space
– Fix actual problems
48
Questions?
(We’re all about questions)
Obligatory:
• We’re hiring! stackexchange.com/work-here
• Open source! stackexchange.github.io
• Follow me! twitter.com/df07
49
50
Here Be Dragons
(rejected slides)
51
• Started with basic OutputCache (cache rendered
HTML for a page)
• ~4% cache hit rate
Caching
52
• Add in-memory & Redis caching
Caching
53
StackExchange.Redis
• Wrote our own library for talking to Redis
• Multiplexing operations over a single connection
• Aware of primary / secondary instances
– Can target reads at secondary slave
54
StackExchange.Redis
(opserver – https://github.com/opserver/opserver)
55
Moonspeak (Localization)
Watch the video with slide synchronization on
InfoQ.com!
http://www.infoq.com/presentations/stack-
exchange

More Related Content

Viewers also liked

Advanced Microservices - Greach 2015
Advanced Microservices - Greach 2015Advanced Microservices - Greach 2015
Advanced Microservices - Greach 2015
Steve Pember
 

Viewers also liked (18)

Streaming architecture with HDP & ELK
Streaming architecture with HDP & ELKStreaming architecture with HDP & ELK
Streaming architecture with HDP & ELK
 
Advanced Microservices - Greach 2015
Advanced Microservices - Greach 2015Advanced Microservices - Greach 2015
Advanced Microservices - Greach 2015
 
Kelompok 2
Kelompok 2Kelompok 2
Kelompok 2
 
#speakgeek - Open Source Software Infrastructure at iconnect360
#speakgeek - Open Source Software Infrastructure at iconnect360#speakgeek - Open Source Software Infrastructure at iconnect360
#speakgeek - Open Source Software Infrastructure at iconnect360
 
Machine Learning & IT Service Intelligence for the Enterprise: The Future is ...
Machine Learning & IT Service Intelligence for the Enterprise: The Future is ...Machine Learning & IT Service Intelligence for the Enterprise: The Future is ...
Machine Learning & IT Service Intelligence for the Enterprise: The Future is ...
 
Item analysis
Item analysisItem analysis
Item analysis
 
Performance Benchmarking of Clouds Evaluating OpenStack
Performance Benchmarking of Clouds                Evaluating OpenStackPerformance Benchmarking of Clouds                Evaluating OpenStack
Performance Benchmarking of Clouds Evaluating OpenStack
 
Nagios Conference 2014 - Fernando Covatti - Nagios in Power Transmission Util...
Nagios Conference 2014 - Fernando Covatti - Nagios in Power Transmission Util...Nagios Conference 2014 - Fernando Covatti - Nagios in Power Transmission Util...
Nagios Conference 2014 - Fernando Covatti - Nagios in Power Transmission Util...
 
IM World presentation from Chris Swan: Application centric – how the cloud ha...
IM World presentation from Chris Swan: Application centric – how the cloud ha...IM World presentation from Chris Swan: Application centric – how the cloud ha...
IM World presentation from Chris Swan: Application centric – how the cloud ha...
 
Persistence in the cloud with bosh
Persistence in the cloud with boshPersistence in the cloud with bosh
Persistence in the cloud with bosh
 
Aws + Puppet = Dynamic Scale
Aws + Puppet = Dynamic ScaleAws + Puppet = Dynamic Scale
Aws + Puppet = Dynamic Scale
 
What does "monitoring" mean? (FOSDEM 2017)
What does "monitoring" mean? (FOSDEM 2017)What does "monitoring" mean? (FOSDEM 2017)
What does "monitoring" mean? (FOSDEM 2017)
 
Application Deployment at UC Riverside
Application Deployment at UC RiversideApplication Deployment at UC Riverside
Application Deployment at UC Riverside
 
Setting up a Digital Business on Cloud
Setting up a Digital Business on CloudSetting up a Digital Business on Cloud
Setting up a Digital Business on Cloud
 
Security For Humans
Security For HumansSecurity For Humans
Security For Humans
 
Sunbrella Ottomans by Outdoor Elegance
Sunbrella Ottomans by Outdoor EleganceSunbrella Ottomans by Outdoor Elegance
Sunbrella Ottomans by Outdoor Elegance
 
Introduction to smpc
Introduction to smpc Introduction to smpc
Introduction to smpc
 
You know, for search
You know, for searchYou know, for search
You know, for search
 

More from C4Media

More from C4Media (20)

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy Mobile
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java Applications
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No Keeper
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like Owners
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate Guide
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 

Recently uploaded

CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
Wonjun Hwang
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
Muhammad Subhan
 
Microsoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdfMicrosoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdf
Overkill Security
 

Recently uploaded (20)

ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi Daparthi
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Microsoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdfMicrosoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdf
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 

Scaling Stack Overflow: Keeping it Vertical by Obsessing Over Performance