How Can I Check My Network and Disk IO Speeds?

MongoDB relies on high speed networking and disk IO. Slow network speeds and slow disk speeds can greatly affect overall system performance

Testing Network Speed

When testing network speed, make sure to test the speed in both directions between all nodes.
For example, if you have a three node replica set with nodes A, B, and C, then you would want to test all of the following combinations:
  • A -> B
  • A -> C
  • B -> A
  • B -> C
  • C -> A
  • C -> B

Testing Network Speed with iperf

The easiest way to test network performance is using the iperf tool.

Installing iperf on Ubuntu

To install iperf on Ubuntu or on other Debian based distributions, run the following command:
sudo apt install iperf3

Installing iperf on Red Hat Enterprise Linux or CentOS Using EPEL

On Red Hat Enterprise Linux (RHEL), CentOS, or other Red Hat based distributions, iperf is located in the Extra Packages for Enterprise Linux (EPEL) repository. If you have this repository enabled, you can install iperf by running:
sudo yum install iperf3
If you do not have access to EPEL, then you can directly download the iperf rpm.

Installing iperf on Mac OSX using Homebrew

On Mac OSX, iperf is available through Homebrew by running the following command:
brew install iperf3

Installing iperf on Windows, FreeBSD, and other Operating Systems

Binaries for other operating systems are available from the iperf website. Make sure that you download the most recent version of the iperf 3.x series.

Running iperf

  1. Start an iperf server instance on the receiving node:
    iperf3 -s
    
  2. Start the iperf client on the sending node, replacing hostname with the hostname or IP address of the receiving node:
    iperf3 -c hostname
    

Testing Network Speed with NetCat on Linux, Mac OSX, FreeBSD, and other UNIX-like Operating Systems

If you are unable to use iperf to test network speeds and you are using a UNIX-like operating system, you can use NetCat instead.

Installing NetCat on Ubuntu

To install NetCat on Ubuntu or other Debian based distributions, run the following command:
sudo apt install netcat

Installing NetCat on RedHat Enterprise Linux or CentOS Using EPEL

On Red Hat Enterprise Linux (RHEL), CentOS, or other RedHat based distributions, install NetCat by running the following command:
sudo yum install nmap-ncat

Installing NetCat on Mac OSX using Homebrew

On Mac OSX NetCat is available through Homebrew by running the following command:
brew install netcat

Using NetCat

  1. Start a server process on the receiving node using the following command. You can change 12345 to another port number if necessary:
    nc -vvlnp 12345 >/dev/null
    
  2. Run the following command on the sending node, replacing hostname with the hostname or IP address of the receiving node:
    dd if=/dev/zero bs=1M count=1K | nc -vvn hostname 12345
    
    To test the network speed, NetCat sends 1GB of data over the network to the receiving node.

Testing Disk Speed

Using dd to Test Disk Speed on Linux, Mac OSX, and FreeBSD

To test disk IO speeds with dd on Linux, run the following command::
dd if=/dev/zero bs=1M count=1K conv=fdatasync of=/data/test.bin
On Mac OSX, FreeBSD, and other UNIX-like operating systems, run the following command:
dd if=/dev/zero bs=1048576 count=1024 of=/data/test.bin
Both of these commands write a 1GB file called /data/test.bin. Change the path as needed so that the file is written on the same filesystem where the MongoDB database files are located.

Using winsat to Test Disk Speed on Windows

On Windows you can use the winsat utility to test disk IO speeds. Run the following command as an administrator, replacing c with the drive that contains the MongoDB database files.
winsat disk -ran -write -drive c
For more information, see the winsat documentation.

Comments