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.

If a NFS client reads a file, does any network traffic happen? or is it just writes (by any node) that result in network traffic?

In particular, I'm interested in whether doing a file_exists() call in a PHP script will be more expensive if the target file is on NFS than if the target file is on the native file system?


For reference, this is my NFS configuration:

Server /etc/exports:

/var/www/staging/uploads 192.168.0.1(rw,sync,no_root_squash)

Client /etc/fstab:

192.168.0.1:/var/www/staging/uploads /var/www/staging/uploads nfs soft,intr,rsize=8192,wsize=8192
share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Reads will cause traffic. file stat() calls will cause traffic. Clients have a cache, but it is very short-lived and is really not something one can rely on.

No one ever accused NFS of being fast and efficient, although it can be tuned.

share|improve this answer
    
Would this still apply if I use noatime in the client /etc/fstab? –  Tom Jul 20 '10 at 6:09
    
If the data lives on the other machine, there will be network traffic frequently. You might want to write a small test php script that does a few 10's of thousands of file_exists() locally and then over your NFS mount to see the speed difference. It's not so much "is it slower" as "is it fast enough" I suspect. –  Michael Graff Jul 20 '10 at 6:13
add comment

Yes traffic does occur. In your particular use case, PHP will test to see if the file actually exists.

However, you would be surprised just how popular NFS is for web services. I can think of one large blogging house whom use is as a file store for images. However they only call a file from NFS once and then its cached.

The best thing to do is to profile your script a few times to see how much overhead is involved with the NFS request Vs. a Local Request. Xdebug will help you there.

To determine how much network overhead is involved, run TCPDump/Wire shark while the request is being made. Then review the output. This should give you an idea of what would be involved in each request.

You could also mount the NFS share with the UDP option. This will speed things up quite a bit.

You do need a fast backend network if you are going to push this out to a very buys web farm. So if you do have they capability to use local storage, I'd try and do it.

share|improve this answer
add comment

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.