Networking – Why is Samba SMB slower than HTTP/NFS/FTP transfer on NAS on the LAN

home-networkingnasraspberry pisambawireless-networking

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

Best Answer

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.

Related Question