Slow nfs write performance if lots of files exist in directory


#1

I’m trying to copy a directory from an EXT4 filesystem to a NFS mount, but write performance so slow, it is around 100 KB/sec.

Source directory have about 5000 small files (from 5Kb to 300Kb) and length of the filenames around 64 bytes.

When I try to copy a single large file on the same setup, I’m getting 25 MB/sec write performance which is quite acceptable for me. But, with the directory described above, it is nearly impossible to complete copy operation.

I tried with nfs cache (fsc), noatime, nodiratime, rsize and wsize options without any success.

Filesystem on the NFS server is XFS, so working with 5000 files in a directory is not a hard job for the NFS server.

What can be wrong with this setup? How can I increase the file copy performance?


#2

You can use async export option in NFS server side.

It is document in: man exports

async: This option allows the NFS server to violate the NFS protocol and reply to requests before any changes made by that request have been committed to stable storage (e.g. disc drive).
Using this option usually improves performance, but at the cost that an unclean server restart (i.e. a crash) can cause data to be lost or corrupted.

If you enable async option on server side, you will get a performance improvement. But as explained in manpage, your writes can be lost on the server side.

You can also enable async mount option on the client side, it can also helps a little bit more on the performance.