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
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.
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.