4

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
  • What, exactly, is this “USB drive”? A regular hard disk? How’s the CPU load on your Pi? – Daniel B Apr 28 '15 at 13:43
  • USB drive = 3 1/4 inch hard disc with external case. CPU load on the pi job when transferring file only 5-6% – teak Apr 28 '15 at 14:13
  • Please 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. – JakeGould Apr 28 '15 at 14:41
  • thanks, I've added that; though the laptop and wifi variant are common to both scenarios. – teak Apr 28 '15 at 15:09
  • Is it possible to test with the HP connected via wired Ethernet to see if the results are different? – Rod MacPherson Apr 28 '15 at 16:37
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.

  • thanks 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 Apr 29 '15 at 8:59
  • I was able to increase Wi-Fi transfer speed using HTTP to 3-4MiB/s. – teak Apr 29 '15 at 10:17
2

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.

0

Based on the details provided in the question, here are some factors that could affect the local transfer rate:

  1. The resources on the Raspberry Pi
  2. The read speed of the hard drive connected via USB (read speed should typically be high but not sure if drive is faulty)
  3. The USB drivers on the Raspberry Pi
  4. The USB connecter/external case that connects the hard drive to the Raspberry Pi

Things that can be done to isolate the issue:

  1. Connect the "USB Drive" directly to the workstation you are using and check the transfer speed
  2. Use a wired connection on the Raspberry Pi (if not already setup this way)
  3. Copy files from the "USB Drive" to a different storage on the Raspberry Pi and check the transfer speed
  4. Copy files from the Raspberry Pi (from the eMMC not from a USB)
  5. Create a webserver and/or ftp server on the Raspberry Pi and have the files transferred to the workstation over http and ftp while the workstation is on both wireless and wired connections (4 different scenarios - http with laptop on wired, http with laptop on wireless, ftp with laptop on wired, ftp with laptop on wireless)
  6. Connect the "USB Drive" to a different workstation on the network other than the Raspberry Pi and check the transfer speed. Try this using both wired and wireless connections.

Assumptions:

  • There are no other devices reading from the "NAS" that has been setup which could also affect the transfer rate.
  • You are not connected to your network using both a wired AND a wireless connection. If you are, there is a chance that traffic to the internet uses one interface and local traffic uses another which might affect the transfer speeds as well.
  • 2
    He 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. – MaQleod Apr 28 '15 at 14:59
  • Comments are not for extended discussion; this conversation has been moved to chat. – Mokubai Apr 30 '15 at 11:37
0

Simply put: NFS, FTP and HTTP are leaner protocols than the earlier versions of SMB. Though I would always advocate against using FTP for file transfer because where it might be leaner than SMB it lacks many of the features that makes remote storage safe.

Later versions of SMB does bring it more inline with NFS however it sounds like you might be running Samba 3.x which is pretty old (albeit a lot easier to set up).

While we are discussing throughput, I would also advise against running NTFS on the Raspberry Pi as Linuxes NTFS driver is ntfs3g which runs in FUSE. For those who aren't aware of FUSE, it's a way to write file system drivers that run in the user space rather via the FUSE wrapper rather than devs having to write kernel modules. This means you can write drivers faster, safer and in more interesting ways (eg I've written FUSE drivers that convert the contents of text files into a virtual file system) however that comes at a cost since you're constantly swapping data between the kernel and user space. This will be less noticeable on PCs -and ntfs3g is pretty well written too which helps- however on a lower footprint device like the Raspberry Pi that extra CPU and memory overhead will have a knock on your performance versus streaming data from a Linux-native file system like ext3/4 or XFS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.