NFS Performance Testing on Linux: A How-To
In this article
This guide shows you how to measure the performance of an NFS (Network File System) mount on Linux. You'll learn to test throughput (read/write speed), latency, and IOPS (input/output operations per second) using standard command-line tools. This helps you identify bottlenecks, compare server configurations, and verify that your NFS setup meets expected performance targets.
What You'll Need
- A Linux client with NFS support (most distributions include it by default).
- An NFS server that is already exported and mounted on the client. Verify with
mount | grep nfs. - Root or sudo access to install tools and run some tests.
- Basic familiarity with the Linux command line.
- Optional: a second client to test concurrent access.
Step-by-Step
- Install benchmarking tools. Most tests use
dd,bonnie++, andfio. Install them if missing:sudo apt install bonnie++ fio # Debian/Ubuntu sudo yum install bonnie++ fio # RHEL/CentOS/Fedora - Check the mount options. Run
mount | grep nfsand note the options (e.g., rw, vers=4.2, tcp). These affect performance. For consistent results, ensure the mount is using TCP (default) and a modern NFS version (4.x). - Create a test directory. On the NFS mount, create a dedicated directory for tests to avoid mixing with real data:
mkdir /mnt/nfs_test - Test sequential write throughput with dd. Write a large file (e.g., 1 GiB) and measure the speed:
The output shows the transfer speed (e.g., 100 MB/s). Repeat 2-3 times to get a stable average.dd if=/dev/zero of=/mnt/nfs_test/testfile bs=1M count=1024 conv=fdatasync - Test sequential read throughput with dd. Clear the cache first (to force actual NFS reads) and then read the file:
Note the speed. This tests the server's ability to deliver data.sudo sync; echo 3 | sudo tee /proc/sys/vm/drop_caches dd if=/mnt/nfs_test/testfile of=/dev/null bs=1M - Test latency and IOPS with fio. Create a small file and run a random read/write test with a queue depth of 1 (latency-sensitive) and a higher depth (IOPS):
The output includes read/write IOPS and latency (clat, slat). For a more realistic test, increasefio --name=randrw --rw=randrw --bs=4k --size=64M --numjobs=1 --iodepth=1 --runtime=30 --time_based --directory=/mnt/nfs_test--iodepthto 16 or 32. - Run bonnie++ for a comprehensive test. Bonnie++ tests file creation, deletion, and sequential I/O. Run with a file size at least twice the client's RAM for meaningful results:
This creates a 2 GiB file and 16 files for metadata tests. It outputs a table with per-operation speeds.bonnie++ -d /mnt/nfs_test -s 2048 -n 16 -m NFS_TEST - Test with multiple clients (optional). If you have another client, run the same fio test simultaneously on both to see how performance scales and whether the server becomes a bottleneck.
- Analyze the results. Compare your numbers with the expected performance of your network (e.g., 1 Gbps network caps around 110 MB/s). If you see far lower throughput, look for issues like network congestion, server disk speed, or NFS configuration.
Common Mistakes
- Not clearing caches before read tests. If the file is in the client's page cache, dd will read from memory, not the network. Always drop caches before read tests.
- Using too small a file. A 10 MB file finishes too quickly and doesn't reflect sustained performance. Use at least 256 MB, or better, 1 GiB or more.
- Ignoring mount options. Options like
rsizeandwsize(negotiated automatically) can affect performance. Check withnfsstat -m. - Forgetting to sync. dd writes may be cached in the client's page cache. Using
conv=fdatasyncensures data is written to the server before dd finishes. - Running tests during peak hours. Other traffic on the network or server load will skew results. Run tests in a controlled environment.
Tips
- Run each test multiple times and take the median, not the first result.
- Test both small and large block sizes. NFS performance varies significantly with I/O size.
- Use
nfsstat -o netto see NFS-specific statistics like retransmissions, which can indicate network issues. - If you're testing a new server, run a quick baseline with
ddon the server's local disk to know the theoretical maximum. - For sustained tests, use
fiowith--runtime=60or more to detect throttling or overheating.
Troubleshooting
- Very low throughput (e.g., 10 MB/s on 1 Gbps). Check network link speed with
ethtool eth0. Check for packet loss withping -f server_ip. Also, verify the server's disk is not the bottleneck by running a local dd test on the server. - High latency but decent throughput. This often indicates network latency (e.g., high round-trip time). Use
pingto measure RTT. NFS over WAN will have higher latency than LAN. - Test fails with "Permission denied". Ensure the test directory is writable by your user. Check NFS export permissions on the server (
/etc/exports). - fio reports "No space left on device". Your test file size exceeds the available space on the NFS mount. Reduce
--sizeor free up space. - Results vary wildly between runs. This could be due to server-side caching, background jobs, or network interference. Run tests at a quiet time and increase the duration.
Frequently Asked Questions
What is a good NFS performance number?
It depends on your network and server hardware. On a 1 Gbps LAN, expect around 110 MB/s sequential throughput. On 10 Gbps, you can see 500-1000 MB/s. Latency for small I/O should be under 1 ms on a LAN.
How do I test NFS over UDP?
NFSv3 supports UDP, but it's rarely used due to reliability issues. To test, mount with -o udp and run the same tests. Expect lower throughput and higher packet loss on busy networks.
Can I test NFS performance without installing tools?
Yes, you can use dd alone for basic throughput tests, as shown in steps 4 and 5. For latency and IOPS, you need fio or bonnie++.
How do I test NFS with a specific block size?
With dd, use bs= (e.g., bs=64k). With fio, use --bs=64k. Test multiple sizes (4k, 16k, 64k, 1M) to see the impact.
What is the difference between throughput and IOPS?
Throughput measures how much data is transferred per second (MB/s). IOPS measures how many I/O operations are completed per second. Small random I/O is IOPS-bound; large sequential I/O is throughput-bound.
Should I test with NFSv3 or NFSv4?
Test both if possible. NFSv4 has more overhead but better security and locking. Performance differences are usually small, but you should test the version you plan to use in production.