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.

We have two Solaris servers, let's call them Alice and Bob.

We also have a Solaris NFS server used by both of them, call it Charlie.

Alice writes to a text logfile on the NFS server, which is then read by Bob, who acts on events in that logfile.

The issue we're having is that there appears to be some delay in Bob seeing updates to the file from Alice.

For testing, I ran on Alice:

while [ 0 ]; do echo `date` | tee -a dummy_logfile; sleep 1; done

This just writes out the output from date every second to a textfile, which is stored on the NFS server.

On Bob, I do:

tail -f dummy_logfile

I've noticed that there appears to be a delay of ~ 3 seconds for Bob seeing events. The tail -f will echo a logline, then pauses for around 3 seconds, then it spits out 3 seconds worth of log lines, then another 3 seconds of nothing, then outputs another set etc.

However, if on Bob I do:

while [ 0 ]; do cat dummy_logfile ; sleep 1; done

It repeats each line in dummy_logfile near instantaneously.

So it looks like tail -f reading the NFS share is delayed, but cat reading over the NFS share is not. I was under the impression that tail -f was near-instant.

Is there anything in the interaction of NFS, buffers, cache, etc. that might explain this behaviour? Does each cat somehow force an update or something?

Also, doing a tail -f on Alice (the server generating the dummy_logfile) seems to be near-instant, so it doesn't appear to be some issue with tail -f itself.

Cheers, Victor

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I believe tail -f looks at the attributes of a file to determine the EOF point, but attributes are normally cached for a certain amount of time in NFS. cat simply streams all the bytes.

Mount NFS with the option "noac". This will disable all attribute caching. By default, attributes are cached for a minimum of 3 seconds, which is coincidentally exactly how long your delay seems to be. You can modify the option "acregmin=x" to set that lower, but it seems you'd want the caching disabled entirely.

Caution: this will probably incur a performance hit if you're using the NFS share for anything else.

More NFS info at the man page here: http://linux.die.net/man/5/nfs

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.