# NFS slow write speed with sync option

## Xandão

Hi All

I have a NFS server that exports its /home partition.

When I mount this partition using sync option in client I have a normal read speed but a VERY SLOW write speed like I show below:

```

read:

floyd asaraujo # time dd if=testfile of=/dev/null bs=16k count=4096

4096+0 records in

4096+0 records out

67108864 bytes (67 MB) copied, 5,65682 seconds, 11,9 MB/s

real    0m5.665s (FIVE SECONDS... NORMAL)

user    0m0.002s

sys     0m0.115s

write:

floyd asaraujo # time dd if=/dev/zero of=testfile bs=16k count=4096

4096+0 records in

4096+0 records out

67108864 bytes (67 MB) copied, 365,004 seconds, 184 kB/s

real    6m6.412s (SIX MINUTES!!!)

user    0m0.023s

sys     0m1.292s

```

The fstab entry for this mount is:

```
myserver.mynetwork:/home             /home/asaraujo/teste_nfs     nfs     sync,hard,intr,rw,nolock,rsize=32768,wsize=32768,timeo=7,retrans=3    0 0
```

When I mount the same with async option I have good read and write rates like this:

```

read:

floyd asaraujo # time dd if=testfile of=/dev/null bs=16k count=4096

4096+0 records in

4096+0 records out

67108864 bytes (67 MB) copied, 5,6147 seconds, 12,0 MB/s

real    0m5.621s

user    0m0.004s

sys     0m0.109s

write:

floyd asaraujo # time dd if=/dev/zero of=testfile bs=16k count=4096

4096+0 records in

4096+0 records out

67108864 bytes (67 MB) copied, 5,92363 seconds, 11,3 MB/s

real    0m7.339s

user    0m0.001s

sys     0m0.191s

```

In this case, the fstab entry is:

```
myserver.mynetwork:/home             /home/asaraujo/teste_nfs     nfs     async,hard,intr,rw,nolock,rsize=32768,wsize=32768,timeo=7,retrans=3    0 0
```

The only change is sync by async.

Is this a normal behavior of NFS??? When I use sync I have extreme confidence but a great loss of speed???? Or probably is something wrong????

If I use async instead of sync it can be considered that my system is much less confident than when I use sync or am I being paranoic???

Thanks!!!

----------

## desultory

Though perhaps not quite to the extent described, I would expect such behavior.

Setting the sync option on a filesystem is supposed to keep the data present in the filesystem synchronized with the data cached by the kernel regarding that filesystem. Considering that NFS is, obviously, using a network connection (even if it is accessed over a loopback device) using the sync option when mounting an NFS share would be expected to introduce significant latency in all write operations as buffering is largely (at the filesystem level) removed from the filesystem.

Note that mounting local storage with the sync option active also causes increased write latency though it is typically less obvious.

----------

## Xandão

Thanks desultory

I´d expect an increase of latency with sync option, but not with that magnitude (6 seconds to 6 minutes to write the same amount of data). This could be considered "normal"??? If yes, the use of sync option makes impracticable its use in most of  current network applications, in my opinion.

If I use async option, I can consider my system unsafe or, like I said initially, am I being paranoic?

Thanks!

----------

## mounty1

Adding

```
rsize=1024,wsize=1024
```

 to the /etc/fstab mount options solved it for me.  I think that the problem is if your packets exceed the MTU of your network device.

----------

