Network share: Performance differences between NFS & SMB
The NAS device will be the target for read and write operations. It has a hard disk with a transfer rate of around 150 MB/s. All devices are connected over LAN. The NAS device is linked to FritzBox with 1000 Mbit/s. The bit rate between PC and FritzBox is set to 100 Mbit/s.
|AVM FRITZ!Box 7390 Wlan Router||Kubuntu 15.04 64Bit|
|Synology DiskStation DS213J||DSM 5.2-5565 Update 2|
|WD Red NAS-HDD 1TB (150MB/s R/W)||Linux bash utils (cp, time, rm)|
I have decided to use NFSv4 and SMBv2 with large MTU. An important difference between both protocols is the way they authenticate. NFS uses the host-based authentication system. This means that every user on an authenticated machine can access a specific share. However SMB provides a user-based authentication. Since NFSv4 it’s possible to use a Kerberos server, which extends the authentication system.
Enabling NFS and SMB in a Synology NAS (DSM) is done with a few clicks. As you can see below I have restricted read and write access to the network segment 10.10.0.0/24, which allows the access to a total amount of 254 hosts. You might split your network segment into two regions. The upper hosts might get read access whereas the lower hosts might get additionally write access. Just play around and find the configuration which meets your requirements.
Network share access with Linux
sudo apt-get install nfs-common cifs-utils
sudo mount -t cifs //IP-OF-YOUR-NAS/NAME-OF-SHARE /mnt/smb/ -o user=YourUserName
sudo mount IP-OF-YOUR-NAS:/NAME-OF-SHARE/ /mnt/nfs
Network share access with Windows
The SMB share can be mounted without any additional Software. The line below mounts the SMB share to drive X:\
net use X: \\IP-OF-YOUR-NAS\NAME-OF-SHARE /USER:YourUserName
If you own a Windows 7 Ultimate or Enterprise license, you can turn on Services-for-NFS inside Windows-Features. Others need 3rd-party software to access NFS shares. To be honest, accessing NFS is horrible if you don’t own the correct windows license. It’s not as easy as in Linux or Mac OS!
A solution, which is offered by the University of Michigan is only usable in TESTMODE. The provided driver is not digitally signed!
NFS vs SMB – Benchmark
Every test was repeated three times. The results were rounded up or down.
|Files||NFS (write)||SMB (write)||NFS avg.||SMB avg.|
|10 KiB (6998 files)||38s||37s||37s||95s||106s||102s||37s||101s|
|1 MiB (240 files)||24s||23s||23s||26s||29s||27s||23s||27s|
|500 MiB (1 file)||46s||45s||45s||45s||45s||45s||45s||45s|
|3,5 GiB (1 file)||323s||323s||324s||325s||324s||323s||323s||324s|
Write example: (time cp -f ~/tmp/test/10KB/* /mnt/smb/test/10KB/) && (rm -f /mnt/smb/test/10KB/*)
After each read test the local cache must be cleared. Otherwise the measurement will be wrong.
|Files||NFS (read)||SMB (read)||NFS avg.||SMB avg.|
|10 KiB (6998 files)||25s||26s||26s||60s||57s||57s||26s||58s|
|1 MiB (240 files)||24s||24s||25s||28s||29s||27s||24s||28s|
|500 MiB (1 file)||45s||45s||45s||48s||50s||48s||45s||48s|
|3,5 GiB (1 file)||323s||323s||345s||345s||349s||346s||330s||347s|
Read example: (time cp -f /mnt/nfs/test/1MB/* ~/tmp/test/1MB/) && (rm ~/tmp/test/1MB/* && sudo sh -c 'echo 1 >/proc/sys/vm/drop_caches' && sudo sh -c 'echo 2 >/proc/sys/vm/drop_caches' && sudo sh -c 'echo 3 >/proc/sys/vm/drop_caches')
As you can see NFS offers a better performance and is unbeatable if the files are medium sized or small. If the files are large enough the timings of both methods get closer to each other. Linux and Mac OS owners should use NFS instead of SMB. Sadly most Windows users are forced to use SMB.