Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am planning to use NFS to serve out many small files. They will be read very often so client side caching is crucial. Does NFS handle this? Is there a way to increase the client side caching in some way?

...or should I look at another solution? Syncing using rsync or unison periodically is not an option since the files are modified on the client side from time to time.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

First, NFS does not provide cache coherency, so if you need that, you must look elsewhere.

What NFS specifies is a weaker model called close-to-open consistency. Meaning that when a file is closed, any dirty data are flushed to the server. Conversely, when a file is opened, an attribute check is performed, meaning that if the client has cached pages from that file, it checks whether those pages are still valid.

While not in the spec itself, most NFS clients have something called attribute cache timeout, i.e. how old the attributes of a directory or opened file can be before the client contacts the server to revalidate them. On Linux, see the actimeo= etc. mount options. Higher values allow more aggressive caching, but increase the risk of using stale data if some other client updated the file in the meantime.

share|improve this answer
    
Thank you for your reply. So, just so that I've understood this correctly, the client side "attribute cache" only contains a cache for file/dir-attributes ie. the cache doesn't contain any file content? –  Ztyx Apr 8 '10 at 7:26
    
Yes, the client caches file content in the page cache, just like it does for a local filesystem. The attributes are used to decide if and when the cached file contents are invalidated. –  janneb Apr 8 '10 at 10:35
    
Ah. Thank you so much for answering this. Have a nice day. –  Ztyx Apr 8 '10 at 13:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.