Why Mongodb performance better on Linux than on Windows?

vjHuang picture vjHuang · Jun 12, 2014 · Viewed 9.5k times · Source

I created a programme to test sharded MongoDB performance on Linux(Ubuntu) and Windows(Server2008). With inserting large quantity of records, Windows's disk's active time is very high(100%), then performance is very bad. But on Ubuntu, the disk's util% is 60%~70%, and the performance is better than Windows. Can I say MongoDB performance better on Linux?

Answer

Markus W Mahlberg picture Markus W Mahlberg · Jun 12, 2014

First: all of the filesystems abailable on Windows 2008 server are very, very inefficient. Compared to XFS or ext4, they are up to 40% slower when both the Windows and Linux file systems are optimized.

Second: latency might be an issue. The network stack on a current Linux system simply is faster than on a W2008 server.

Third: if you have a firewall running on your box, latency becomes an even bigger problem for remote access. While Linux' iptables is fast and efficient enough so that the great part of firewall appliances is based on it, the firewalls available for Windows are not, for various reasons.

Plus: Windows is not as efficient with RAM as Linux is. MongoDB uses as much RAM as possible (up to the point it needs), for example for storing (copies of) index files in RAM. Windows takes a much larger share of the available RAM than a Linux machine. So index files might be read from disk than from RAM, which is orders of magnitude slower.

Bottom line: it is a Really Bad Idea™ to run a production mongoDB on a Windows system.

EDIT

As per request in the comments:

You might have recognized that I referenced three reports by Principled Technologies. While I am not affiliated with them in any way, IMHO they made a good job in comparing RHEL 6 and Windows Server 2012 by using industry standard benchmarks and explicitly optimizing both OSes for the task in question as well as using out of the box OSes.

One might argue that this comparison does not prove that all GNU/Linux distributions are faster than Windows Server 2012, the features we are talking about are ones provided by the Linux Kernel and are usually not fiddled with, so it is safe to assume that similar results can be expected from all major distributions.

With the in part extreme performance advantages of Linux (the TCP stack of Linux' is as much as almost 4 times as fast as Windows Server's for large message sizes, which tends to be the case in database applications), I renew my assertion that it is a Very Bad Idea™ to run a production MongoDB on a Windows System.