95 comments

[ 3.3 ms ] story [ 163 ms ] thread
Anyone know why systems like this aren’t Linux based? Seems rather ironic when stack overflow seems to be a staple of the open source/sharing community.
They started with .NET MVC + SQL Server which was not running on Linux back then.
IIRC from previous articles, HAProxy and Redis are key components too.
running on linux servers, too. (as well as the ELK stack, which handles logging)
IIRC when Joel Spolsky and Jeff Atwood started Stack Overflow, they both had strong expertise in the Microsoft ecosystem. So they used the skills and knowledge they already had.

It was quite the coup at the time for Microsoft, especially the SQL Server team, to have such a high profile, high-traffic site.

Spolsky is former MS and familiar with their stack.

Additionally, SQL Server is a very good database, fast, reliable and feature-rich.

Additionally part 2: Microsoft owns Github, can’t get more open source than that!

MS owning GitHub is a very recent thing in GitHub's development, so that isn't really a good comparison. I doubt getting bought by MS was anything like the plan in the early days!

> Spolsky is former MS and familiar with their stack

That is key: often experience (i.e. the cost of problems caused by lack of experience) can outweigh licensing considerations, particularly in the fast moving PoC/prototype stages and the subsequent quick growth phase.

> Additionally, SQL Server is a very good database

No argument there. While other DBs could certainly do the job too, SQL server is a good choice, even without that "experience bonus".

You couldn’t run .NET on Linux (well) back then, and they wanted to implement it using .NET.

License costs wouldn’t be a good reason to pick another stack over the one you know.

Mono supported ASP really well as far back as 10 years ago. Stack Overflow launched 11 years ago, and I didn't try it then, so perhaps they just missed out?

Although, tooling was very heavily Windows based at the time (no Rider); so it is understandable why StackOverflow took the direction they took.

Have you actually used old Mono? I remember sluggish performance, especially of its stop the world garbage collection.
Also, the standard library for ASP.NET either had gaps or somewhat incompatible implementations of features. I’d give time to attempt a port of a mid-size web forms app every couple years but ran into a number of issues each time.

It was an amazing achievement, but never quite got me there.

no. Maybe ASP MVC4+ worked well with Mono, but WebForms and MVC below 4 was/is just horrible.
Mono had crap performance on .NET MVC and also some things just did not work. Mono would be horrible, horrible choice for website like SO.

Source: Was runnin .NET on Mono 7 years ago or so.

> Source: Was runnin .NET on Mono 7 years ago or so.

That's not a source. This is a source:

http://www.techempower.com/benchmarks/

Yes, it does show Mono's ASP performance is substantially worse than .NET, and probably more-so in 2008. I never said otherwise.

There are a lot of things to take into consideration when selecting a tech stack for a brand new, entirely unproven product. It's certainly on the list, however if performance ranks highly, then I'd be seriously questioning the diligence of whoever made said list. Expenditure (e.g. Windows Server licensing fees) would rank high on the list, however so would developer familiarity with a given stack as well as tooling familiarity.

As I said, I can see why StackOverflow made the decision they made, but I'm doubtful performance was, at that time, a major driving force.

Nothing ironic here. Stackoverflow wasn't designed for open source software. It is a Q and A system for all Developers. People who develop in proprietary technologies also need help when developing. They also share code. A lot. Not sure what gave you an impressiopn that SO is a Linux community because it is not.
They consider the Windows + .NET stack to have saved them more money than they pay in licensing et al.

At the time, major "web development" stacks that people would have thought of on Linux tended to be much more resource hungry (still are), meanwhile the people behind StackOverflow had very good .NET skills that they could apply immediately. This translated into being able to serve more people per server than if they used, let's say, PHP, Ruby, Python, etc.

And as people said, SQL Server. Which is a very, very capable database server with impressive performance.

I am not sure what your statement is based on regarding linux being more resource hungry than windows. Have stats to back this up? Same for goes for the SQL Server’s “impressive performance”.
The stacks, not the system. At the time StackOverflow was built, the main Linux stacks were either PHP, Rails, Django, or similar, which, while good, are not as performant.
I am puzzled, what are these statements based on? "Linux stacks were either PHP, Rails, Django, or similar, which, while good, are not as performant." - first time I hear a .NET/Windows/SQL Server stack is more performant than these.
The performance of PHP was a joke when Stack Overflow started. It has gotten way better since, but back then it was reading, parsing and compiling every single script your page loaded, for every single page load. You could hack around this with an accelerator module like APC or Zend, but why bother learning how to code around PHPs limitations, when you're already fluent in C# that's plenty fast without any hacking.

Not sure how the story goes for Rails, but Python (Django) used to be a pig when SO was started over a decade ago, for similar reasons as PHP.

> Python (Django) used to be a pig when SO was started over a decade ago, for similar reasons as PHP.

Django's execution model is not at all similar to how PHP code is being run. Pretty much every python web server uses wsgi (or mod_python before that) which relies on a persistent app server. Whatever are the reasons for django's assumed performance issues, PHP's runtime model had nothing to do with it.

PHP performance is still a pig, which is pasted over by various caching behaviours (for example in OS). I have to deal with making HA for a PHP site whose design precludes keeping read-only copies of PHP code, and have to load them form NFS... let's just say that even with php.ini tweaks it involves pretty much constant reads of code.
First time hearing doesn't make it not true. For some historical perspective: MS engaged in a performance battle (which they won) vs Netscape Web Server running on Solaris (with IIS) since 1995 or so, including making changes to the NT kernel. So it wouldn't surprise me this attitude continued forward into the recent era. SQL Server has similarly been in a performance battle with Oracle for decades. MS has whole teams just dedicated to performance, to creating performance engineering tooling etc.
Interestingly, Stack Overflow is using several of those tricks to speed up their internal services, as the kernel-side HTTP server is made available to everyone, it's not locked to MS applications. AFAIK they have few "microservices" which don't use IIS but handle HTTP through HTTP.sys

SQL Server has huge amounts of tuning and cooperation with NTFS driver team to ensure good performance, and frankly, it's at the high-end of the databases, and I really wouldn't mind using it except for price :(

Compiled code is faster than interpreted code. C#.NET is a compiled lamguage and doesn't need to be interpreted at runtime. Making is faster than interpreted languages like PHP, Rails, Python etc. These days, some interpreted languages are now cheating and interpret only at first run. Then skip interpret step on subsequent runs.

C#.NET performance is up there with C++. C#.NET is only slower than C++ during garbage collection. When garbage collection is done, it is back in business and running at the same speed.

> C#.NET is a compiled lamguage and doesn't need to be interpreted at runtime.

That's not a great summary. .Net is complex. There's AOT compilation but not available for all purposes. There's JIT which applies most of the time to C# code compiled into msil. From there different things can happen depending on implementation, which may also include running the code via an IL interpreter.

Doesn't just Mono have an interpreter (which is now being added as part of tiered compilation)? Aside from .NET Micro. I was under the impression that .NET by and large was JIT-only. Yes, by now it's more complex, and there have been multiple different implementations, few of which would be relevant on a Windows Server environment for ASP.NET. But AFAIK a situation like in Java where the official implementation has an interpreter and a JIT (and debugging usually falls back to interpreting with horrible performance) has never been the case in .NET.
last time I checked, AOT is heavily used, and if you load your assemblies into GAC you're getting AOT compilation for pretty much all code if you're not going to generate bytecode at runtime.
C#/.Net/Windows was (is?) at worst as performant than Java/Linux but probably was more performant. Twitter switched from Rails to Java in order to scale up and end their constant whaling, because Rails performance was that terrible.

Put those things together, and it’s fairly evident that C#/.Net greatly outperformed the Django/Rails stacks that were popular at the time.

You forgot JavaEE? Wouldn't that have been the main contender at the time?
1. Their team didn't have expertise with JavaEE.

2. JavaEE??? What has the StackOverflow team done to make you hate them so much? :o)

From Atwood/Spolsky podcasts it seems like Spolsky had zero impact on tech stack. Jeff Atwood was at the time C# programmer so he wrote StackOverflow in C#.

More context: https://blog.codinghorror.com/why-ruby/

I wonder if they would make the same decision about Discourse and Ruby today, given that .NET Core is now a thing and open-source?
I bet not, it was clearly a hype-decision for Discourse.
It was because his cofounder, who was doing more of the initial coding, was most comfortable with Ruby.
Why should it be? Honest question.
That was my first reaction when I saw this comment. Why should everything be in Linux? Also considering that SO does the job and does it very well.
Cause it is more work to manage windows servers than it is to manage Linux servers. Less work is better than more work so Linux is better for server implementations.

But I guess that is something people will argue over for a long long time.

Well... my opinion, based on my experience...

If you have people experienced in managing Windows, but not Linux, then it's less work to manage Windows servers.
You can learn how to manage Linux and then get even less work.

Anyway...

I was certainly not saying that there are not scenarios where it is better to go with windows servers. Things don't happen in a vacuum.

There's always a better solution for something that you can learn. But would it be better for everybody if the SO authors spent months learning Linux administration and non-.net web platform, or if they applied their existing knowledge to create SO immediately?
No, I just said it wouldn't be better... there are many scenarios where the best way to do something in one perspective is not the best seen from another perspective.
> Cause it is more work to manage windows servers than it is to manage Linux servers.

This isn't true. I managed and supported a fleet of Windows and Linux servers for a web hosting company for 14 years. Both OS's have their time sinks and gravity wells of failure.

So both have time sinks... how does that permis effect my statement? I said one is worse. You say both suck time, which is obviously true, work takes time.

You can disagree with me ok, but if you want to convince me that I am wrong it would be nice with substantiated material.

You hadn't offered any substantive material in support of your own opinion either.

As a sysadmin with 30 years of experience running Linux and Windows servers though, I'll offer my own anecdote - I'd say that Windows is far easier to manage for many common scenarios. It's all point and click and you can basically figure out what to do without looking at any documentation anywhere.

It's so easy, you can teach a monkey how to configure a workgroup, domain, users, dns server, firewall, etc. on Windows.

Also, which Linux distro are you talking about? What with all the fragmentation, nothing is ever the same on every distro.

That's putting it mildly. A lot of the time things aren't even the same on the same distro 2 years later, which is incredibly annoying when the only documentation you can find is for the wrong version.
I did not substantiate my claim cause I did not argue against anything.

Figuring stuff out without documentation when there is documentation is a bad idea. If you know what to do the GUI can guide you a bit, but it does not do work for you. If you want to do something that you don't understand you should really read more about it, the context being irrelevant.

I doubt you could teach a monkey to do anything like that.

At my last work we used the same distro for everything, why make it hard for yourself. Personally I think most things are the same in the most commonly used distros. Everything is generally just a file. Use mount to mount disks /dev /etc /var folders all standard normal stuff.

Well, why shouldn't it? The way I see it, a FOSS technology stack should be the default, and using the proprietary and expensive one must be justified, as in saving significant amounts of money, or coming with some absolutely necessary technical advantages. The fact that SO is an exception (a high-profile site built on MS stack while not being affiliated with MS) kind of proves the point.
>a FOSS technology stack should be the default, and using the proprietary and expensive one must be justified

You're ignoring overall Total Cost of Ownership (TCO). Licenses are a drop in the ocean compared to the cost of long term ongoing management of your platform(s).

It would be interesting to see if they could move their hosting to Linux with something like Mono, even if just testing and seeing what the performance difference is for web nodes. I guess those are rarely the actual bottleneck, but still.
They are in the process of migrating to .NET core, which runs on Linux.

Wether they choose to move to linux is a different matter.

It would be interesting to get a guesstimate for the licensing costs of all this.
I wouldn't be surprised if the software is very heavily discounted, given that it's a very high-visibility public website frequented by people who make technical decisions.
The number of production nodes appears to be small - less than 10?
Around a dozen servers at https://stackexchange.com/performance . Around $1k for Windows per machine, around $5k per SQL * 4 servers.

All in all, well under $50k in licensing costs. Basically a rounding error, if you compare to something like AWS billing for a website of the same scale.

> around $5k per SQL * 4 servers.

I wish. Microsoft SQL Server Enterprise Edition (which is required if you want to use over 128GB RAM for caching data, or servers with over 24 cores) costs approx $7,000 per CPU core.

Yikes! For contrast, Buffer burns through $20k per month in managed hosting ( https://open.buffer.com/transparent-pricing-buffer/ ). Running a site at scale is an expensive ordeal
What does this SAAS has anything to do with MS server pricing
It gives perspective on how expensive running a company on the internet is, from a hosting-and-servers perspective. MS server pricing is steep, but the cost of licensing over the useful lifetime of a SQL server is not a big cost factor.
I wonder what they are using websockets for? I haven't seen push notifications on SO.
We use websockets for pushing things like comments, answers and question edits as they are added as well as for notifications like inbox messages and reputation updates.

Our websocket process currently has ~500k concurrent connections across 9 web servers.

Nick has some information on his blog (https://nickcraver.com/blog/2016/02/17/stack-overflow-the-ar...) although it’s a little outdated - we no longer use Netgain, we use the .NET Core websockets bits instead.

What about CAL licenses? :))
Don't need them for SQL server hosts, you need them for AD (one per user) or login connections (other than admin).
Whenever I read something like this (and I'm not blaming MS here, most tools are like this) it seems that configuration and setup of systems is still in the chipped stone age... No services (or versions of services) talk smoothly with each other, setup is very prone to mistakes and it's just a big pain overall.

(Windows probably makes it a bit hard though)

Personally, I am not a huge fan of Windows, .NET and SQL Server, but this is a good example of a company using the right tool for the task at hand, rather than copy pasting popular stacks. It would be really interesting to see some stats, benchmarks, or any interesting metrics to help understand the benefits or drawbacks of using this tooling. There is way too much focus on Linux, to the point where I am worrying that Linux itself is becoming a monopoly, and it might end up not benefiting from good competition.
There is a high-level overview of the Stack Exchange servers at

https://stackexchange.com/performance

More details are scattered across various places, e.g. Nick Craver's blog (https://nickcraver.com/blog/) and the Stack Overflow and Stack Exchange meta sites.

Nice one, thanks for this.
I've got some clients on dedicated servers and some on cloud, the performance differences are staggering. Cloud seems so bad. For what you pay for in cloud it really feels like you get 10x the performance for the same price in dedicated hosting.

This really underlines it. Running one of the most popular sites on the web with just 9 web servers, 2 SQL servers and a smattering of dedicated role servers. But that popularity ultimately boils down to 450 req/s, and they've got a nice, fast site.

No faffing around with "scaling" up and down to handle the fact the cloud servers are slow. It always feels you get nowhere near the listed performance and are constantly getting throttled.

I would guess a lot of startups would be better off paying a few grand a year for a couple of dedicated servers and just forgetting about AWS/Google Cloud/Azure.

While true in a lot of cases, the answer is still not a binary yes or no. AWS/Azure/GCP still add a lot of quality of life improvements to workflows. Performance is not the only metric to compare on. There’s also productivity, time and opportunity costs. There are real benefits in outsourcing or buying off the shelf.

Second, it also depends on wether you are write or read heavy. SO is primarily read heavy and they can get away with most requests never hitting their main servers but instead being handled by a CDN.

But overall I do agree. Dedicated would give you a performance boost compared to virtual machines. And sometimes it might be worth it to bring stuff in house and do it yourself.

Does the word monopoly even have meaning when the "product" is open source? It's not like a single company controls linux, it is contributed to and grows from input from many people and many companies worldwide, all of whom have an interest in seeing it flourish.

Is HTML a monopoly? Is JS a monopoly?

IMO it does have meaning, in the a technical sense, not necessarily commercially. JS does monopolize browser scripting. Now that you mentioned it, it's quite interesting that there are basically no competitors to JS, in the browser.
> it's quite interesting that there are basically no competitors to JS, in the browser

Because the next best way to change a standard is add another one?

For all the moaning about javascript over the past decades, it has evolved into a fairly formidable language since 2015.

I’m not even sure introducing a new language would help anything at all. It would simply be quickly adopted by those the very same abusers.

Maybe the solution instead is to have better browsers and implement better privacy policies.

I like JS, actually. It would be great to have some diversity tho. Also i agree on having better browsers.
You are right that monopoly only applies in a market. Sometimes the word ‘monoculture’ is useful to describe this kind of situation.

However there is a large amount of diversity within Linux, so I would hesitate to call it a monoculture.

I will be honest and just say this: As a Linux guy who has negligible familiarity with the Windows Server technology, this post doesn't make much sense to me.

What is the Linux equivalent of this operation? apt-get dist-upgrade? Now that Windows 10 onward is rolling release (is it?) is this the last time SE staff is going to have to go through this?

This caught my attention:

> Putting the 2019 server into the existing 2012 cluster – as expected, this fails due to the operating systems being different.

How can a website be this tightly coupled with the operating system it's running on? Shouldn't Microsoft be blamed that their operating systems are not backwards-compatible? To my knowledge, Microsoft goes to extreme lengths to assure backwards-compatibility of the userland apps. What went wrong here?

Windows 10 was designed for desktops, not as a server software. Windows Server 2003/2008/2012/2014/2019 etc is for servers and they don't subscribe to Windows 10 rolling release. They have their release and support cycles. People rarely upgrade.

I have upgraded a website from Windows 2003, to Windows 2008, to Windows 2012 and now it is running on Windows 2019. I jumped 2014 and 2016 because upgrades weren't necessary for my needs. Each time, I only spent 1 hour maximum to migrate the system. I am not even a server guy.

You mean 2016 right, not 2014? Or are you talking about SQL versions?
Yes. I meant Windows Server 2016. Thanks for the correction.
(comment deleted)
The Linux equivalent would be upgrading a database cluster from CentOS 5 to 7, or Ubuntu 12.04 to 18.04.

On a production cluster, you aren't just going to "apt dist-upgrade" and be done, you're going to need to deal with versions of all sorts of things under the hood changing versions as well. In the SO case, they were at least able to keep the database versions the same, but it sounds like some other things were incompatible between the two OSes that prevented them from directly clustering together.

to be fair if you have a production cluster of elasticsearch or postgres you can't just upgrade the DATABASE technology without interrupting the cluster. BUT you can upgrade the OS from CentOS 5 to 7 without a problem. And the Elasticsearch/Postgres Cluster would still be fine
Depends on a lot of things... Often you'll be using the OS provided postgres package, so upgrading from 5 to 7 will probably also involve a big database version update. Do you have any associated tooling or services? They might need updates to work with newer libraries or software updates, such as Python 2.5 to 2.8. Etc...

Over the last couple decades, I've done something around 100 of these sorts of upgrades for clients of a managed hosting service I used to run, and they were rarely simple OS upgrades. Lots of planning and testing went into them.

That's the sort of upgrade this article seems to be about, I'm not sure if it's because SQL Server is tightly integrated with some OS-provided services that were incompatible, but it was certainly more involved than a base OS running only the database and just installing the same database on the new OS.

> How can a website be this tightly coupled with the operating system it's running on?

The post is about their database servers, not the site. Microsoft SQL Server’s high availability and disaster recovery solutions are built atop Windows Server Failover Clustering, which comes with a lot of gotchas. For example, for over a decade, all of the members of a cluster had to be the same major version of Windows. That made upgrades not just difficult, but impossible: you had to build a brand new cluster from scratch every time and then migrate over to it, and destroy the old cluster when you were done.

Microsoft does indeed go to lengths to assure backwards compatibility. This isn’t a compatibility issue - it’s an upgrade process issue.

(Source: I did SQL Server HA/DR work for years, including helping Stack out along the way, but abandoned HA/DR work when it became kinda untenable. Now I focus on the performance tuning side instead.)

Upgrading in a production environment is not as easy as apt-get upgrade. There are tests that need to be run, version incompatibilities that need to be investigated, and plenty of other things that need to be done. The complexity varies but it's almost never as simple as running a little command and going home. To claim otherwise just because it's Windows we're taking about is being specious.
I have an NVMe drive that was rendered non-bootable by a Linux kernel upgrade, and a new Dell bios was needed to get it to boot. Some of these issues happen on linux in general as well.

Non-rolling linux releases (such as ubuntu) run into all sorts of strange issues during a dist upgrade, and you may end up with database servers sufficiently different to prevent them from clustering together.

Windows server has always been versioned differently from desktop windows with 8 LTS versions since 2003.

Best part is the second part, where they stop upgrading to 2019 cause it destroys their SSDs:

https://www.tarynpivots.com/post/how-stack-overflow-upgraded...

I'm Taryn's coworker I was involved in that part of the process very closely.

That statement is not entirely accurate. The SSDs certainly did die, but not _because_ of the 2019 upgrade, it just happened at the same time as the 2019 upgrades.

The major 2019 SSD issue was however that Intel and Dell kept passing the buck on who was to blame for not having 2019 drivers for the NVMe SSDs. Eventually I ended up having to bully Intel into giving us the drivers. We decided that "bullying Intel" was not an appropriate future tactic for getting the next version of the drivers, so that's another factor for staying on 2016 (which has drivers we've tested for years)

Interesting, how does one bully Intel? I wanna bully Intel too (/s)
I'm surprised by all the negative comments here surrounding how Windows Server or SQL Server makes this more complicated, or whether the license costs are prohibitive.

I worked as a .NET dev for nine years, and although I've never had to deal with upgrades at this level before, I can appreciate that at the kind of scale that Stack Overflow operate, and considering they run on physical boxes (a rarity in any stack nowadays) any kind of upgrade between major database and OS versions is going to result in its own issues.

While I don't work on the Microsoft stack any more, I've always appreciated the way that Stack Overflow build their software. Their engineers and DBA's seem to be a who's who of talent, and they both build great services and put out great content, at scale. It's doubly-surprising when so many people used to give Jeff Atwood so much shit for not delivering anything of note when Coding Horror was one of the top programming blogs on the web.

The stack might be very different to anything done in 2019, but the fact that I can't think of many times where Stack Overflow went down shows that they're doing a great job, and hopefully they'll continue to document the journey for years to come.

I'm a big Linux fan, and use it as my daily driver but I can't understand why so many people are talking about Linux when it's been very clearly explained why the chose an MS stack.

They had already got experience with it! That's why they chose it. In my opinion go with the stack you have experience with, don't just do what everyone else is doing.

I like how Stack Overflow, in a market that is ripe to bash everything and anything, has no qualms about discussing running .Net and SQL Server.

I've been a software engineer for over two decades now and I've seen stuff come and go. The products Microsoft is shipping today are impressive bits of technology and, and the end of the day, do what you want them to do and do that very well. And I've been through the more difficult years where I wish I had thrown SQL Server off a cliff.

Why am I bothering to write this? Because I'm still in technology and I wish people would stop jumping on the next bandwagon or pointing to the next shiny object. There are tried-and-true technologies out there that shouldn't be ignored based on prejudices. Stack Overflow is a great example of a company who understands this.