Linux – How to speed up and cache mmap file access over NFS on Linux

cachelinuxnfs

The server and client are both 64-bit Ubuntu 10.04 LTS.

The application in question is a custom app that uses mmap() for fast random file access. Its ideal state is when the entire file is cached in RAM.

The network connections are really fast 10Gb Ethernet. It is a virtual server blade setup.

It isn't the network connections slowing things down because everything performs superbly when using a virtual disk (iSCSI to the SAN). But when we run the application on a NFS home directory mount, performance goes to the dogs.

It appears that the Linux kernel isn't caching anything. So it is reading every single disk block needed by mmap() accesses over and over and over again.

The NFS mount is done through autofs, which has only default settings. /proc/mounts shows the NFS mount is done with the following options:

rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.11.52,mountvers=3,mountproto=tcp,addr=192.168.11.52

How can I make Ubuntu 10.04 cache the file instead of reloading it all the time?

Best Answer

Have you tuned your NFS exports or mounts at all? What are your present mount options? Which filesystem are you using on the NFS server?

I know you're using Ubuntu, but this NFS tuning guide from Red Hat might be a good start, especially if you have a good performance metric to test with different settings. Some of the hints in the document cover limiting metadata changes when accessing files over NFS and extending the attributes cache.

Is NFS caching (FS-Cache, CacheFS) an option in this case?

Related Topic