I have two diskless systems setups. Both of them mount /home directory from the same server. The /home export is Kerberized and works without problems, only performance seems to be the issue. Everything is connected to the same switch, using the same cables, port configuration is the same, etc. fstab mount options are a bit different, because NFSv3 and NFSv4 have different subsets of them.
I copied about 25000 small files (smaller than 10kb) to /dev/shm/dir (to copy physically between the server and a client) on each client, and then rsynced them to my ~. Times differ by about 15 seconds. Does anyone know why this happens? Is NFSv4 slower than NFSv3? Or is there a specific option, that could improve the situation? I would greatly appreciate some help.
Server
Debian "Bullseye", 5.10.0-23-amd64 #1 SMP Debian 5.10.179-1 (2023-05-12) NFS Export: /home 1.2.3.4/24(rw,async,no_subtree_check,sec=krb5:krb5i:krb5p) # cat /proc/fs/nfsd/versions -2 +3 +4 +4.1 +4.2 Client1 using NFSv3
Debian "Bullseye", 5.10.0-23-amd64 #1 SMP Debian 5.10.179-1 (2023-05-12) # cat /etc/fstab 5.6.7.8:/home /home nfs rw,nodev,nosuid,hard,nolock,proto=tcp,nfsvers=3,sec=krb5 0 0 # findmnt └─/home 5.6.7.8:/home nfs rw,nosuid,nodev,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=krb5,mountvers=3,mountport=40531,mountproto=tcp,local_lock=all [client1] /dev/shm ➽ $ time rsync --links -r dir ~/dir1/ real 0m33,835s user 0m0,582s sys 0m6,062s Client2 using NFSv4.2
Debian "Bookworm", 6.1.0-11-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.38-4 (2023-08-08) # cat /etc/fstab 5.6.7.8:/home /home nfs rw,nodev,nosuid,ac,hard,proto=tcp,nfsvers=4.2,sec=krb5 0 0 # findmnt └─/home 5.6.7.8:/home nfs4 rw,nosuid,nodev,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=krb5,local_lock=none [client2] /dev/shm ➽ $ time rsync --links -r dir ~/dir2/ real 0m48,155s user 0m0,671s sys 0m8,472s Edit: Sep 10th, 11:53
I read some statistics from the mountstats. Additionally i mounted the /home with krb5p and it turned out that encryption does not impose any visible impact on the throughput. Metodology:
cat /proc/self/mountstats > /dev/shm/mountstats.start- run
rsync mountstats mountstats --since /dev/shm/mountstats.start > nfs.mountstats.rsync.txtmountstats iostat --since /dev/shm/mountstats.start > nfs.iostat.rsync.txt
NFSv3 client ops/s rpc bklog 1874.078 0.000 read: ops/s kB/s kB/op retrans avg RTT (ms) avg exe (ms) 0.000 0.000 0.000 0 (0.0%) 0.000 0.000 write: ops/s kB/s kB/op retrans avg RTT (ms) avg exe (ms) 159.312 228.017 1.431 0 (0.0%) 0.720 0.843 NFSv4.2 client ops/s rpc bklog 1436.392 0.000 read: ops/s kB/s kB/op retrans avg RTT (ms) avg exe (ms) avg queue (ms) errors 0.025 0.062 2.449 0 (0.0%) 0.500 0.500 0.000 0 (0.0%) write: ops/s kB/s kB/op retrans avg RTT (ms) avg exe (ms) avg queue (ms) errors 129.076 201.433 1.561 0 (0.0%) 0.322 0.407 0.061 0 (0.0%) Edit: Sep 11th, 9:33
I made additional NFS server using Debian "Bookworm" 12 and created a simple, non-Kerberized NFS 4.2 share on an nvme Drive. There is no difference, the same rsync took about 50 seconds. So, this is not an operating system/kernel/hardware issue apparently, but it is NFS-related.
Then, I mount the same share using NFSv3 and the rsync took about 26 seconds. So, is really NFSv4 that slow when compared to NFSv3?
Edit: Sep11, 18:29 (in response to @ron answer)
are you the only other one on the system (both nfs-server and nfs-client)
Currently I have two setups, one shared with other machines, but almost no one was using the share at the time of tests and the I/O was at idle levels. The second setup is private.
is there any other network load;
No more than "idle" traffic at the time of tests. We have 10 Gbps core fiber optics uplinks, workstations have 1 Gbps uplinks. HP Enterprise switches. To minimize network problems (we also do not want to push this traffic through the router) the NFS server and all workstations are in the same subnet and connected to the same switch. And this is not a new setup, I'm only trying to switch from NFSv3 to NFSv4.
You set up the network and have full control of the switches/routers, > or was that all set up and managed by people you've never met
I control the hardware and did the setup.
and also possibly along with the kerberos security setup... adding security to improve performance, said no one ever.
I tried both Kerberized and non-Kerberized mount, both showed that NFSv3 was faster than NFSv4.
I stumbled upon this by accident. We have almost 200 workstations, which boot diskless. Everything works fine in general. This year, when setting up the new system (newest Debian 12) using NFSv4 I noticed, that copying an unpacked archive (with a lot of small files, icons, some symlinks) is somewhat long. So I decided to check if copying takes about (I do not care about small variations) the same time on the previous NFSv3 system. It turned out that it takes longer on NFSv4. I tried with and without Kerberos, always using TCP (proto=tcp).
I thought that there is a lot of variables in the equation, so please let us forget for a moment about Kerberos, etc. I setup this private system:
- no Kerberos
- server exports a single directory located on an nvme drive
- client mount the exported directory, no kerberos, only
nfsvers=4.2,ac,rw - Both client and server are Dell workstations with 1 Gbps Ethernet
- Both client and server are connected to the same switch and are in the same subnet (VLAN), so no router in the network traffic
- Both client and server run the same operating system and kernel: Debian 12 "Bookworm"
6.1.0-12-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.52-1 (2023-09-07)
Then I did (several times) this simple test:
- Get the archive with files to copy to
/dev/shm. This one: https://github.com/vinceliuice/Tela-icon-theme/archive/refs/tags/2023-06-25.tar.gz - unpack the archive
rsync --links -r unpacked_archive /path/to/mounted/nfsshare/dest
It took about 50 seconds.
- Then i remounted this share using NFSv3
- and repeated the same test
It took about 30 seconds.
So, same machines, same network, no kerberos, same system, same kernels, only NFS version is different -- and there is a big difference. It is interesting and I would like to know what is happening and learn something. At this moment getting all this into consideration I have no other answer than just NFSv4 is simply slower. I found very old article about NFSv4 performance and expected that a lot has changed since, but maybe not in this case?
NFSv4 file creation is actually about half the speed of file creation > over NFSv3, https://www.linux.com/news/benchmarking-nfsv3-vs-nfsv4-file-operation-performance/
In my case I'm creating a lot of small files on the mounted NFS share.
Why trying this with many small files is important? Because students use Git, large IDE's create many small files, sometimes hundreds and more, students compile a lot of software, etc. And there is a lot of students -- so thousands and thousands of small files.
Sep 12, 10:55 (test results)
We never had any issue with tranfering large files, we do it on a daily basis and speeds are about full uplink speed. But regardless I did the copying test with the large file. /nvme is a NFS share.
/dev/shm ➽ $ dd status=progress if=/dev/zero of=test.file bs=1M count=6000 3488612352 bytes (3,5 GB, 3,2 GiB) copied, 1 s, 3,5 GB/s 6000+0 records in 6000+0 records out 6291456000 bytes (6,3 GB, 5,9 GiB) copied, 1,80348 s, 3,5 GB/s [orange14] /dev/shm ➽ $ rsync --verbose --progress test.file /nvme/test.file sent 6.292.992.082 bytes received 35 bytes 105.764.573,39 bytes/sec total size is 6.291.456.000 speedup is 1,00 I also did several scp copies and noted times.
[orange14] /dev/shm ➽ $ time scp test.file /nvme/test.file6 real 0m59,463s real 0m59,700s real 0m59,780s It is about 105 MB/s.
As for the test with the machines with larger amounts of RAM, I do not have spare servers now that I can use to this purpose, and at this moment I do not have that much time to spare on such detailed tests of NFS in general. I repeated some test for small files and plotted them. Both server and client were Dell workstations, the same OS, the same kernel, no Kerberos, just simple NFSv3 or NFSv4.2 share. I was copying the same archive over and over again.


-r archiveI think you intended-r --archive. // Create one big25k.tarfile. How do the client 1 vs 2 timing statistics compare? That is, are we primarily seeing a timing effect on metadata?-o rdirplusenabled?rdirplustofstab, but it is not visible in the full mount options on the client. I do not know why. I also uploaded a new image. The previous one had statistics when copying was done from mounted/home, not from/dev/shm. It added some READ ops, but did not change write times.