Why is Samba SMB slower than HTTP/NFS/FTP transfer on NAS on my LAN?
Solution 1
TLDR: SMB & AFP have bulkier encryption and actually do more than just show you an index of the files. FTP and NFS are just there to give you a list and get the job done. Your RPI as mentioned in another comment is hardware restricted to the USB bus that moves all I/O data. But 2-4Mbps is garbo so check your client and update all your software, 10-18Mbps sounds more legit unless your RPI or comp are defective.
Doesn't appear to matter what hardware is used, Samba is simply slow. AFP (Apple File Protocol) is no better, I have been working with AFP and SMB since 2008 using both Windows and Mac, it's evident that I found more freedom with Linux especially since they've really improved laptop wifi capabilities and the economy is popping things like C.H.I.P. and RPIs out their ears. But the point is, SMB, AFP, NFS and FTP all have their downsides. SMB can be improved if you remove some of the security features and same goes for AFP. The reason why you can see improvement in FTP is the very bare bones transferring that it is, there's no encrypted handshake. NFS locks files and similar to FTP isn't made for "opening" (copying from the host machine to your memory) and editing files, unlike SMB and AFP which are designed to act as though you're browsing the host machine.
Solution 2
The SoC device used on the Pi does not have builtin support for ethernet so the ethernet functionality on the Pi is provided by a USB-ethernet chip, sharing the same USB bus as any other USB peripheral you might have connected to it (including any USB flash drives). This is probably the main reason why you see abysmal performance.
Solution? Sadly there is none, it is a hardware limitation. It has nothing to do with the speed of your hard drive or the network setup you have, the USB bus on the Pi is pushed to its limit with both the disk and ethernet running concurrently.
You might want to invest a little more in your NAS setup and purchase a single board computer that does indeed have builtin ethernet. There are several platforms with gigabit ethernet support out there.
Related videos on Youtube
teak
Updated on September 18, 2022Comments
-
teak almost 2 years
I want to set up a NAS which I have done most recently with a Raspberry Pi 2 (quad-core ARM Cortex-A7, 1GB RAM, 32GB microSD) running Raspbian “Jessie”:
- I have a laptop—an HP Pavilion G6—running Ubuntu 14.04 and using 802.11b/g/n.
- I have an external USB 2.0 NTFS hard drive connected to a Raspberry Pi 2, using Samba and Apache, connected to the LAN of my wireless router at 100Mbps.
- When I try to transfer a file using Samba SMB from the Raspberry Pi 2, I get transfer rates at less than 1Mib/s.
- When I transfer a file using HTTP from the Raspberry Pi 2, I get a typical transfer rate of around 3-4Mib/s [better, but still pretty slow].
- When I transfer a file using FTP from the Raspberry Pi 2, I get a typical transfer rate of around 2-4Mib/s [better, but not as good as HTTP].
Why is it that transferring file using Samba SMB would transfer slower [3-4 times] than the same file using HTTP?
I don’t expect 10-12Mib/s—although close to it would be nice—from my local network as there are limitations with the network speed being at 100Mbs, connecting being USB 2.0 and Wi-Fi limitations, but at least it should be better than the Internet which has all these bottlenecks plus whatever else is outside.
Could it be a Samba configuration issue?
Test results [1.5Gb file transfer rates]:
USB 3.0: 70-80MiB/s
Only USB.
USB3.0 external hard drive connected to the USB3.0 port of the HP Pavilion G6 laptop.
File transferred with Dolphin file manager.
source: USB3.0 hard drive
destination: HP Pavilion G6 laptop
USB 2.0: 20-30MiB/s
Only USB.
USB3.0 external hard drive connected to the USB2.0 port of the Raspberry Pi.
File tested using pv
raspberry~$ pv source > destination
.Ethernet LAN: 8-9MiB/s
Wired.
USB3.0 external hard drive connected to the USB2.0 port of the Raspberry Pi.
HP Pavilion G6 laptop connected to network via Ethernet LAN.
File transferred using samba
smb://
.source: USB3.0 hard drive
destination: HP Pavilion G6 laptop
Internet file: 2-3MiB/s
Wi-Fi.
HTTP Wi-Fi LAN speed: 3-4MiB/s
Wi-Fi.
USB3.0 external hard drive connected to the USB2.0 port of the Raspberry Pi.
HP Pavilion G6 laptop connected to network via 802.11b/g/n Wi-Fi.
File on apache webserver
http://
.source: USB3.0 hard drive
destination: HP Pavilion G6 laptop
NFS Wi-Fi LAN speed: 3-4MiB/s
Wi-Fi.
USB3.0 external hard drive connected to the USB2.0 port of the Raspberry Pi.
HP Pavilion G6 laptop connected to network via 802.11b/g/n Wi-Fi.
File transferred with Dolphin file manager.
source: USB3.0 hard drive
destination: HP Pavilion G6 laptop
FTP Wi-Fi LAN speed: 2-4MiB/s
Wi-Fi.
USB3.0 external hard drive connected to the USB2.0 port of the Raspberry Pi.
HP Pavilion G6 laptop connected to network via 802.11b/g/n Wi-Fi.
File on vsftp server
ftp://
.source: USB3.0 hard drive
destination: HP Pavilion G6 laptop
SMB Wi-Fi LAN speed: < 900KiB/s
Wi-Fi.
USB3.0 external hard drive connected to the USB2.0 port of the Raspberry Pi.
HP Pavilion G6 laptop connected to network via 802.11b/g/n Wi-Fi.
File transferred using samba
smb://
.source: USB3.0 hard drive
destination: HP Pavilion G6 laptop
How can I improve this?
Here is the output of
iwconfig
on my laptop:wlan0 IEEE 802.11bgn ESSID:"Irk" Mode:Managed Frequency:2.412 GHz Access Point: 34:31:C4:02:46:2D Bit Rate=65 Mb/s Tx-Power=20 dBm Retry long limit:7 RTS thr:off Fragment thr:off Power Management:off Link Quality=63/70 Signal level=-47 dBm Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:1369 Invalid misc:12350 Missed beacon:0
Here is info on my Raspberry Pi’s network connection via,
dmesg | grep eth0
:smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
-
Daniel B about 9 yearsWhat, exactly, is this “USB drive”? A regular hard disk? How’s the CPU load on your Pi?
-
teak about 9 yearsUSB drive = 3 1/4 inch hard disc with external case. CPU load on the pi job when transferring file only 5-6%
-
Giacomo1968 about 9 yearsPlease edit your question to address the following: You say you are using, “802.11 Wi-Fi” but what variant? 802.11b? 802.11g? 802.11n? 802.11ac? It might help to know exactly what make/model of your laptop is as well as how your Wi-Fi is provide and what the exact make and model might be.
-
teak about 9 yearsthanks, I've added that; though the laptop and wifi variant are common to both scenarios.
-
Rod MacPherson about 9 yearsIs it possible to test with the HP connected via wired Ethernet to see if the results are different?
-
teak about 9 yearsthanks Rod, did that Ethernet transfer rate: 8-9Mb/s. faster. which is what I might expect from wired LAN.
-
MaQleod about 9 yearsHe could also test using dd from the Pi to the drive and see if it is just the Pi's ability to read/write on the drive.
-
teak about 9 yearsthanks Hamza, I know about this shared chip but I am not sure this is the issue here; I think, as using the Ethernet interface alone seems ok [I can get ~9Mib/s with it]. the common factor here is looking like Samba and/or Wi-Fi
-
teak about 9 yearsI was able to increase Wi-Fi transfer speed using HTTP to 3-4MiB/s.
-
Mokubai about 9 yearsComments are not for extended discussion; this conversation has been moved to chat.