1

I want to use my RPi4 as a small home NAS. To do that, I'm trying to benchmark the maximum file transfer performance.

Workflow:

  1. Rpi4 connected to home router with a 1 Gbit cable

  2. computer connected to home router with a 1 Gbit cable

  3. in order to avoid variations due to the microSD card speed itself or the USB external hard drive speed, I create a 500MB file in a RAMdisk:

    sudo mkdir /mnt/ramdisk
    sudo mount -t tmpfs -o size=512m tmpfs /mnt/ramdisk
    sudo dd if=/dev/urandom of=/mnt/ramdisk/500MB bs=1M count=500 iflag=fullblock   # random 500MB file
    
  4. then I copy via SFTP this file from RPi's /mnt/ramdisk/500MB to my laptop's SSD

I get the following results:

  • When nothing is additionally plugged on USB ports, I get 32 MB/sec transfer

  • When I plug an external USB 2.5" external hard drive without its own power supply (supply from USB), without using it, still using transfer from RAMdisk, I get 15 MB/sec only!

    So I had my answer ready ... the USB external hard drive takes too much power and this is the reason for the performance drop! But it seems that no: indeed the next test is a mystery:

  • When I plug an external USB3 external hard drive which has its own power supply (with an adapter for the HDD only) to the RPi4 (USB2 or USB3 port tested, idem), without using it but just plugged in, still using the RAMdisk, I get 15 MB/sec too!

Question: which maximum transfer speed over SFTP from RPi to computer do you get? if possible with a similar workflow from above: RPi + computer with ethernet cables, no Wifi, transfer a file from RPi (in RAMdisk) to computer (on SSD)

Basj
  • 800
  • 3
  • 21
  • 49

2 Answers2

4

I have an Rpi4 8GB with a WD Elements 2TB USB3 external HDD (USB3 powered from the Pi) and a Seagate Backup Plus USB 3TB (with its own power supply), both shared by the Pi using Samba and I can get 100 Mbyte/sec each way from either on my LAN, maxing out the Gigabit Ethernet. SFTP is slow because of encryption/decryption. Also, if the drives are formatted NTFS then any Linux server is going to bog down because of the CPU load. My Samba shares are formatted ext4.

(1) 11.6 GB file from Pi to Windows PC

enter image description here

(2) The same file from Windows PC to Pi

enter image description here

(3) You will not get such high speeds with lots of small files (Rpi to Windows PC)

enter image description here

(4) For comparison, using WinSCP for an SFTP transfer from Pi to Windows PC.

enter image description here

Another factor is power. Although earlier Pis may work fine with various "charger" type wall warts which the owner may have lying around, the Raspberry Pi Foundation makes clear that later Raspberry Pis, especially the 3 and 4 models, are very fussy about power supplies, and for the 4 the official PSU is strongly recommended. Devices intended for battery charging duty may allow the voltage to sag below 5V when current draw goes over a certain level. You want 5.1V / 3.0A DC output, and it must be capable of doing both these at the same time!!! This goes double if you are powering external devices via the PI. The total USB draw allowed is 1.2A, which is, realistically, ONE external USB drive. Really people purchasing the Pi 4 should order an official PSU at the same time.

Michael Harvey
  • 1,410
  • 8
  • 11
0

My problem was a combination of two factors:

  • using SFTP instead of Samba share. Using Samba massively increases the speed, as detailed in @MichaelHarvey's answer

  • the PSU that I used did not deliver enough current: the RPi was "throttled":

    /opt/vc/bin/vcgencmd get_throttled   # throttled=0x50005: under voltage, currently throttled!
    

Now that I bought the official RPi power supply, it is no more throttled (throttled=0x0), and I can enjoy 110 MB/s speed when transferring from RPi ramdisk to computer over a Samba share (both RPi and computer with 1Gbps ethernet cables).

enter image description here

I did a similar test in the other way, sending from computer to RPi (ramdisk), and I get similar speed:

enter image description here

Now the tricky thing will be to find the best filesystem both readable on Windows (if one day I need to connect the external HDD to Windows), and having good write performance on RPi (exFAT? NTFS? etc.), but it's out of topic for this precise question

Basj
  • 800
  • 3
  • 21
  • 49