Why would NFS have lag after a minute of inactivity

networkingnfsperformance

I am running a version 4 NFS server on a Salix server with kernel 3.10.17. I am mounting the NFS share with the command

sudo mount -t nfs 10.0.0.150:/share /mountpoint

on my client machine, which is the most recent version of Xubuntu (but I've had this problem with this NFS share across several different flavors and versions of Ubuntu clients over the past several years). The first time I access this mount point, such as through the file manager (just for an example, but any other kind of access has the same symptom), I have to wait 20 seconds before the data from the share loads. Once that happens, I can browse through the shared folders without any delay, at least until I let the mount go dormant (meaning I don't try to access anything under it) for about a minute, after which I would experience the delay again. My client is also NFS v4.

Here is the output of nfsstat -m on the client:
rw,relatime,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=10.0.0.214,local_lock=none,addr=10.0.0.150

I am sharing the same folder on the server through SAMBA for my Windows clients, and there are no issues with the SAMBA share.

Best Answer

I found the problem. For NFS v4 server, there is a file /proc/fs/nfsd/nfsv4revoverydir (at least for Slack-based Salix). The contents of this folder should be text which names another path. All of the solutions I found for this said to create the path found in that file, and it fixed the problem. In my case, this file was empty. Rather than trying to figure out how to get this /proc file populated properly, I used the work-around of configuring my server to use version 3 of NFS. I did this by editing the file /etc/rc.d/rc.nfsd and adding the option "-N 4" to the line which starts rpc.nfsd

Related Question