Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Mongodb performance better on Linux than on Windows?

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?

like image 897
vjHuang Avatar asked Jun 12 '14 06:06

vjHuang


2 Answers

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:

  • As for the filesystem speed: Comparing Filesystem I/O performance: RedHat Enterprise 6 vs. Microsoft Windows Server 2012
  • As for the inefficient RAM usage, you might want to check it for yourself. How much RAM does a given Windows Server system use while idling? How does this compare to any given Linux Server idling? Let's be nice and assume that the Windows server just needs 128M for its GUI - it is 128MB wasted. Multiplied by 20, which is not a big cluster size, we are talking of 2.5 GB – which could easily make up a config server or arbiter, if not more. And this would be spent on a GUI, for a system which seldomly needs one, if at all. As per hard facts, you might want to read Comparing CPU and Memory Performance: Red Hat Enterprise Linux 6 vs Windows Server 2012
  • As for the speed of the network stack, there are multiple sources, here are two which I tend to refer:
    • Measured Comparative Performance of TCP stacks, older, but we are talking of orders of magnitude, which at least gives an idea
    • Comparing Network Performance: Red Hat Enterprise Linux 6 vs Windows Server 2012

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.

like image 98
Markus W Mahlberg Avatar answered Oct 20 '22 00:10

Markus W Mahlberg


You can say MongoDB's performance on Linux is better than Windows because unlike many other databases, MongoDB heavily rely on Operating System to perform Memory Mapped File operation as mentioned here. As mentioned in previous answer, Windows server 2008 FS is pretty slower than Linux FS (ext4) then it does make sense MongoDB will perform better on Linux than Windows. And it also depends on whether you have 32 bit or 64 bit system.

like image 34
work_in_progress Avatar answered Oct 20 '22 00:10

work_in_progress