LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   NFS slow when reading newly created files (https://www.linuxquestions.org/questions/linux-networking-3/nfs-slow-when-reading-newly-created-files-576716/)

jagb 08-13-2007 05:34 AM

NFS slow when reading newly created files
 
Hi,

Thanks in advance for any help.

UPDATE: I've experimented a little, and can now better summarize the problem:
I have a NFS server. Any file that has been created on the NFS server since the (hard disk) data partition on the NFS server was last mounted will be read very slowly by any client connecting to the NFS server.

My full post, explaining how I cam to this conclusion, is as follows:

I recently set up a NFS server (gentoo; 2.6.20; AMD64 3000) at home. Between the server and my desktop (gentoo; 2.6.22; AMD64 X2 3800) I have a dedicated gigabit ethernet connection. For the most part, it works well -- I can read and write to the NFS server at ~30MB/sec. However, I have discovered a strange issue, which is that if I try to read from a file that has been recently created on the server, the transfer rate drops to ~3MB/sec.

It doesn't seem to matter whether the file is created on the server through through an NFS write, or some other means (i.e. i can create a new file on the server by copying a file from my desktop to the server via NFS, but I also tried ssh-ing into my NFS server, and created a file by duplicating another pre-existing file). In either case, when I try to read the new file, I get very slow read times. It doesn't matter if I unmount the NFS share and then re-mount it; it's still slow.

I thought that maybe the new files were slower because perhaps they were more fragmented than the already existing files; I ruled this out by rebooting the NFS server. Once I reboot the server, I will actually be able to get fast transfer times on the "new" files.

I thought that maybe there was an issue that the new files weren't yet physically written to the disk, and that was the problem. This too seems suspect, because if I use sftp to retrieve one of the "new" files from the NFS box, I get transfer rates of about 30 MB/sec.

In summary, here is a sequence of commands and their results that I tried that emphasizes the problem:

from desktop, ssh into server, then on the server:
cp old_big_file new_big_file
(size of file ~200MB)
then wait a minute or two to let the file be physically written to disk
then, from desktop, sftp into server, get old_big_file
result: ~30 MB/sec
repeat, but for new_big_file
result: ~30 MB/sec --good!
then on desktop:
dd if=/nfs_directory/old_big_file of=/dev/null bs=16k
result: ~30 MB/sec
dd if=/nfs_directory/new_big_file of=/dev/null bs=16k
result: ~3 MB/sec !!!!
umount /nfs_directory
mount /nfs_directory
repeat dd commands -- same results
umount /nfs_directory
mount /nfs_directory
this time, use cp instead of dd -- same results
umount /nfs_directory
<reboot server>
mount /nfs_directory
repeat dd commands
result: fast transfer rates!

One last thing: I also tried the entire command sequence shown above, except replacing <reboot server> with <ssh into server and restart NFS daemon>. That did not solve the problem.

I am new to NFS, and am very confused. Any help at all would be most appreciated. Thank you very much!

UPDATE:
I have tried replacing <reboot server> in the above list of commands with two other actions, to see if they have an effect. The first was <Let the computer sit overnight> -- this did not help. The second was:
ssh into the server
stop nfs (on the server)
unmount the data partition (on the server)
restart nfs (on the server)
This actually worked!


All times are GMT -5. The time now is 06:46 PM.