7 ms·
> As of 2016, Stack Exchange served 200 million requests per day, backed by just four SQL servers: a primary for Stack Overflow, a primary for everything else,
by chadash 8y ago
> As of 2016, Stack Exchange served 200 million requests per day, backed by just four SQL servers: a primary for Stack Overflow, a primary for everything else, and two replicas.
This was the most enlightening piece of the article for me. Their alexa rank today is 48 (globally, 38 in U.S.), so whatever your site is, you are probably not dealing with as heavy a load as them. What techniques do you have to employ to serve this many requests from a single database server?
- viraptor 8y agohttps://stackexchange.com/performance https://stackexchange.com/performance https://nickcraver.com/blog/2016/02/17/stack-overflow-the-architecture-2016-edition/ https://nickcraver.com/blog/2016/02/17/stack-overflow-the-ar... Lots of caching (redis, CloudFlare) and trying not to use the database unless absolutely necessary, I would expect.
- Just_Smith 8y agoThat's the beauty of serving mostly read-only data - you can just cache the most frequented pages. I can't think of a time that I clicked on a link for Stack Exchange that wasn't served via a search engine. I've never purposefully clicked a link from within Stack Exchange, and I've never posted any answers. I can thank those who do for enabling my success in my career, but I'm willing to bet that most Stack Exchange users are just like me.
- prawn 8y ago"I've never purposefully clicked a link from within Stack Exchange..." How do you resist those crazy unrelated questions in the sidebar? Currently shown for me: Did Shadowfax go to Valinor? Is it legal for company to use my work email to pretend I still work there? Why can't we play rap on piano? Can a virus destroy the BIOS of a modern computer?
- antipaul 8y agoThese became so distracting that I applied an Adblock filter to hide the “Hot Network Questions” div, lol!
- powvans 8y agoHa! I do this too. Just the other day I was pair programming with someone who asked "why don't you have those super stupid questions on the right nav bar?"
- tinco 8y agoThat shadowfax one, quora is horrible that way too. You're interested in one bit of canon triva one time, and the site immediately assumes that particular story is all you want to read about, every day for months. I bet gwaihir carried shadowfax to valinor.
- viraptor 8y agoI don't think hot questions are tailored at all, are they? I often get questions from boards I never visited, so I assumed it's a global collection.
- baroffoos 8y agoThat sidebar is my biggest time waster in the day.
- kkarakk 8y agoThey changed it so you can hide hot network questions(without any karma requirement)
- crayonixel 8y agoThanks for pointing that out! Direct link for anyone else looking for it: https://stackoverflow.com/users/preferences https://stackoverflow.com/users/preferences
- flukus 8y agoAlso, caching at the correct granularity. I've seen too many systems that cache on a fine grained level and performance drops because because there are so many cache lookups, even with an in memory cache.
- deleted 8y ago[deleted]
- bradlys 8y agoCaching and a whole lot of it. Most of their pages could be served by a CDN. How much do you think stack overflow is reading vs writing? How often do you even click a link from a stack overflow page once there?
- quickthrower2 8y agoUpvotes are clicked a lot but I guess they are just an api call and can be tuned to be high performance.
- luckydata 8y agoit's also not super critical to show correct numbers in real time for that so there's that.
- bradlys 8y agoI rarely click anything on stack overflow and neither do most people I know. The only ones I know who do that are stack overflow evangelists. I'd guess very few people have an account and use it.
- quickthrower2 8y agoI’m in between. I have an SO score of just 1000, but I vote a lot. Mainly because I’m logged in via oauth anyway so it’s no hassle to do so.
- guelo 8y agoI've taken to using upvotes for bookmarking, that way when I inevitably look the same question up again six months from now I'll know which of the answers I thought was most useful last time.
- why-el 8y agoUpvotes are actually ideal for an in-memory service like Redis that fsyncs less frequently. Even if you lose the last few reads (highly unlikely, with some care), it's not the end of the world.
- oldprogrammer2 8y agoThey have details here: https://nickcraver.com/blog/2016/02/17/stack-overflow-the-architecture-2016-edition/ https://nickcraver.com/blog/2016/02/17/stack-overflow-the-ar... Lots of caching, lots of RAM, SSD storage, and a low-level ORM for SQL.
- merb 8y agowell the "orm" is more like a database driver that can serialize to models than an orm. but consider their stack there are better "starting" alternatives (they also used them before dapper), like Linq2Sql, EF Core, etc... Also compared to other languages Linq and EF Core are way better than most alternatives (besides that some things are just not working, like lateral joins)
- wnevets 8y agoand they're using that very un-hip microsoft .net
- freehunter 8y agoWhich goes to show that the answer to "what technology should I use to start my startup in [current year]" is always "the one you know best" since Joel was a former Microsoft employee before starting Stack Overflow and his other projects.
- pradn 8y agoC#/.NET can be super fun and productive. Use what you know.
- hansflying 8y agoC# is great. It's a high level programming language and it's also super-fast handling ~7.000.000 requests per second on a single server according to the following benchmark: https://www.ageofascent.com/2019/02/04/asp-net-core-saturating-10gbe-at-7-million-requests-per-second/ https://www.ageofascent.com/2019/02/04/asp-net-core-saturati...
- sergiotapia 8y agoC# was great in 2008, then it got kind of enterprisey and closed - not it's ridiculous and getting steam into all avenues of software engineering. It's arguably the most powerful language in the world.
- manigandham 8y agoHow is it closed? It's now better than ever with the new cross-platform .NET Core with all kinds of runtime and language advancements.
- sergiotapia 8y agos/not/now
- 8y ago
- nerfhammer 8y agoSimple: don't hit the database with every request. SO is mostly hosting static text content that updates infrequently and can be very heavily cached. You don't need to read the database to generate every pageview, quite the opposite.
- qaq 8y agoWell you have to remember that outside of cloud unknown blac kbox vcpus, generic networking setups and extremely underpowered storage options exist a different world where you can have a box with 200+ physical cores few TBS of RAM and extremely high performance storage
- lossolo 8y agoWell it's easier than you think (if you know what you are doing). I am serving around 90-100 mil requests per day from one 4-core xeon machine with most of the CPU idle. With around 2500 queries/s to redis and ~2k queries per second to postgres. App is written mostly in Go. A lot of those requests are updates.
- Thaxll 8y agoExcept that Stack Exchange is a very static site so caching and read ratio is probably very high, I guess 99% of the people just type a question on Google land on SE and that's it.
- altmind 8y agoWell, regardless of caching and special ORM, doing 11K peak sql qps on 15% cpu load, is remarkable. They did a great job optimizing the database and access. They probably also save a lot on ops team - running a single sql server with a failover is well-understood, error-resistant and covered in vendor's guides/best practices.
- manigandham 8y agoIt's the outcome of good architecture, application code, and the fact that single row lookups are already just as fast as a cache, especially in SQL Server running on highend hardware. By the way, 200M is less than 2500 requests/second which is not much at all. In terms of actual throughput, they are not that big.
- arbuge 8y ago> By the way, 200M is less than 2500 requests/second which is easily doable. They are probably not spready uniformly throughout the day...
- manigandham 8y agoThey're also not all full page loads either. Their stats show only 66M of those 200M are pageviews.
- franzwong 8y agoIt is difficult to make a conclusion. We can have a simple architecture but we spend 200% effort on tuning every part of the system.
- sparkling 8y agoWhile the 2 servers for StackOverflow is true, if i remember correctly those were two very, very, very beefy machines. Im talking 64 cores and 256GB RAM beefy bare metal, not your average random 4core/4gb VPS.