NFS confusion - writing many small files
        Posted  
        
            by 
                Antonis Christofides
            
        on Server Fault
        
        See other posts from Server Fault
        
            or by Antonis Christofides
        
        
        
        Published on 2012-09-26T14:44:08Z
        Indexed on 
            2012/09/26
            15:39 UTC
        
        
        Read the original article
        Hit count: 350
        
I have a Debian squeeze amd64 which is at the same time a NFS4 server and client (it mounts itself through NFS4). The local directory that leads directly to disk is /nfs4exports/mydir, whereas /nfs4mounts/mydir is the same thing mounted through NFS, using the machine's external IP address. Here is the line from fstab:
176.9.116.102:/mydir   /nfs4mounts/mydir      nfs4    soft  0 0
I have an application that writes many small files. If I write directly to /nfs4exports/mydir, it writes thousands of files per second; but if I write to /nfs4mounts/mydir, it writes 4 files per second or so. I can greatly increase speed if I add async to /etc/exports. (Writing a single large file to the NFS directory goes at more than 100 MB/s.)
I am confused by the description of async in NFS. If my application accesses the local directory, system calls like write and close return even if caches have not been flushed to permanent storage. Apparently this is not true with NFS sync behaviour. However, with NFS async behaviour, even calls like fsync are ignored. Isn't it possible to work like local files, i.e. generally work asynchronously, but honour fsync and O_SYNC?
© Server Fault or respective owner