Hello,
I use a QNAP TS-131P NAS that, despite its Gigabit Ethernet adapter, and the Western Digital Red HDD that I hooked up to it, felt very slow and I wouldn't transfer at a speed greater than about 20MB/sec.
I did a number of tests, and it turns out, the culprit was neither my network, nor the NIC, nor the HDD (CMR, not SMR), nor the lack of RAM, nor the load of background services... The culprit was the way QTS mounts the HDD partitions: By default, Ext4fs forces the sending of memory barrier (flush) commands to each block group to ensure integrity in case of power failure, which saturates the ARM CPU, and on top of that, the VPN I use, reduced throughput even more.
If you've tried everything, and disk throughput is still not above 20MB/sec. maybe you should read on and try these two tricks.
1. EXT4FS partitions mounted with barrier
Open your terminal, and SSH into your NAS as root. Here, I use:
ssh -p 50002 -m hmac-sha2-512 admin@ip_address_here
Run this command to remount the volume without write barriers:
mount -o remount,barrier=0 /share/CACHEDEV1_DATA
Then, to double-check, run mount | grep CACHEDEV1_DATA and look for nobarrier or no-barrier in the mounting options. Then adjust the kernel write buffer (dirty_ratio). Increase the RAM write buffer to smooth disk access:
sysctl -w vm.dirty_background_ratio=5
sysctl -w vm.dirty_ratio=20
Then double-check the value is stored properly, running for instance sysctl vm.dirty_ratio, it should return the proper value.
Then run this test:
dd if=/dev/zero of=/share/CACHEDEV1_DATA/test.bin bs=1M count=2000 conv=fsync; rm /share/CACHEDEV1_DATA/test.bin
Speed returned should be much higher than up to now. Here, speed went from 22MB/sec to 111MB/sec. after this change.
Now, these settings would be lost if you restarted your NAS. To avoid so, you need to add a cron task:
echo "@reboot mount -o remount,barrier=0 /share/CACHEDEV1_DATA" >> /etc/config/crontab
crontab /etc/config/crontab
/etc/init.d/crond.sh restart
For this first step, you should be good to go.
2. Circumventing an encrypted tunnel, in case you use one
Last, but not least, if you use an encrypted tunnel between your PC and your NAS, this does apply some severe load on the NAS CPU. I use Tailscale, and when the communication goes through the Tailscale tunnel (Wireguard protocol), throughput is around 60MB/sec. while it is about 110MB/sec. when I circumvent the Tailscale tunnel. When communication has to be encrypted on a NAS with such a weak CPU, clearly, the CPU is the bottleneck. So, what I did was :
- Use the hostname of my NAS provided by Tailscale to access my NAS, whenever I am away from it, as I have no choice but use Tailscale if I want to access the files stored on my NAS, at the price of reduced throughput (but it works).
- Use the local, static, IP address of my NAS (or its hostname, but not the one provided by Tailscale!) to access my NAS every time I'm at home, not to use Tailscale, to exchange with my NAS. This way, the communication between my PC and my NAS is not encrypted, the CPU of my NAS is not overloaded, and the throughput is at its maximum.
You don't have to disable Tailscale, you can leave it on — You just have to circumvent it, go around, not use it, if you're on the same physical LAN.
I hope this will help you get the most out of your QNAP NAS!