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)

2
  • does raspberrypi.stackexchange.com/questions/99896/… answer your question? Nov 23 '20 at 16:33
  • Doesn't seem like an answer since it does not explain the discrepancy in ethernet speed when a USB drive is connected. All it does is imply the reason is not the same as it is for previous models. @Basj Check if you get anything in the logs like this when you have the drive attached (also check its performance, if you are unsure of that): raspberrypi.org/forums/viewtopic.php?f=28&t=245931 Flailing with the hardware (repeated connect/re-connect) may be slowing other aspects of the system down.
    – goldilocks
    Nov 23 '20 at 16:47
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.

11
  • Thanks for this very useful information. I'll test without SFTP, but Samba. I'll do first a Samba share of /mnt/ramdisk, to see how it behaves. Then I'll plug another USB external disk formatted with ext4, shared with Samba, and I'll see if I can get similar results than you.
    – Basj
    Nov 23 '20 at 23:02
  • @Basj - I've added some screen shots. Nov 24 '20 at 7:22
  • Wonderful @MichaelHarvey, I'll try to do similar tests. Out of curiosity, what MB/s speed do you get if downloading via SFTP (example: WinSCP) Rpi -> computer?
    – Basj
    Nov 24 '20 at 8:48
  • Linked question: I plan to do the same than you: use a WD Elements 2TB USB3 external HDD (USB3 powered from the Pi). Do you think it's ok for a Rpi4 running 24hr/24 365day/365, do you use it that way too?
    – Basj
    Nov 24 '20 at 8:50
  • @Basj SFTP screen shot added; I keep both my USB HDDS running 24/7. Don't place it where it cannot keep cool. Nov 24 '20 at 11:06
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

4
  • 1
    Although earlier Pis may work fine with various "charger" type wall warts, 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!!! Really people purchasing the Pi 4 should order an official PSU at the same time. Nov 26 '20 at 9:39
  • I only realized today how important this 3.0A PSU thing is!
    – Basj
    Nov 26 '20 at 9:42
  • It's in all the Raspberry Pi Foundation material on their web site. Their own forum is a very useful resource, more focussed and expert than anywhere else with Pi information and questions. Good to do pre-purchase research there. Nov 26 '20 at 10:30
  • Starting with Windows 10 Insider Preview build 20211, Windows Subsystem for Linux 2 (WSL2) now includes a wsl --mount command that lets you mount ext4 and other Linux kernel supported filesystems, directly in installed WSL distributions. This means it may well be in mainstream Windows in the not-too-distant future. Another thing you could do now is attach the ext4 USB drive to a Linux VM in VirtualBox and share it via Samba. Nov 26 '20 at 21:36

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.