Cloud vs Pi's: What Should I get?

Cloud vs Pi's: What Should I get?

August 10, 2024

Time to choose - where is it worth to do SelfHosting?

Analysis paralysis - Choosing Small Factor Computer

Sometime ago, I was doing some benchmarks about Raspberry Pi vs Orange Pi and also about Mini PCs vs those SBC.

CV with a RPI4

BMaxB4 vs Asrock X300.
BMax-B4 Mini PC

BMaxB4 vs Asrock X300. Photo by JAlcocerT

CV with a RPI4
CV with a RPI4
Mini PC Setup

This is an image of a BMAX ASRock x300 used as a mini PC.

CV with a RPI4

But lately, I have been giving a try to cloud providers.

And also, I got a new Raspberry Pi 4 (this time 4GB - ARM64, now that prices are reasonable):

Two RPI’s 4

There is a bunch of information on the internet: reddit, youtube and decided to create this post as both, a systematic guide and the results of testing that I could perform.

ℹ️
How to run these tests
  • What I the testing results include:
    • Raspberry Pi 4 2/4GB
    • Raspberry Pi 5 8GB
    • Orange Pi 5 8GB
    • BMAX B4
    • Hetzner Cloud

Big Thanks to Alex 🙌 - For sharing the results of the Raspberry Pi 5 8GB

Power Consumption and Temps

DeviceIdle PowerMax (Power & Temp Seen)Power AdapterYearly 🔌 Cost (USD)
Raspberry Pi 4~2/3w6W5V 3A~$5
Orange Pi 5~3/5~W8W, 80°C5V 4A~$8
BMAX B49W18W & 64°C, fan-~$14
ℹ️
  • Disabling Wi-Fi improves power efficiency. On the BMAX B4 by ~10% (~1W).
  • Calculation
    • Annual kWh = Idle Power in Watts × 24 hours/day × 365 days/year ÷ 1000 (to convert W to kW)
    • Cost = Annual kWh × Cost per kWh (USD)

At the time of writing, I pay ~0.2$/kWh

GPIO

No discussion here - The Raspberries are the absolute winners.

Also in software support.

I have to comment that I prefer BullsEye over Bookworm for the Pi’s for IoT/CV Projects

OrangePi 5 with Latest Kernel 📌
ℹ️
  • You can boot RPi5 from NVMe like so
    • The SD card will still have the boot priority (if it’s there)

Computing vs Volume

DeviceCPUGPURAMDimensions
Raspberry Pi 4Broadcom BCM2711 Quad-core (4x ARM Cortex-A72)VideoCore VI @ 500mhz2/4 GB85.6mm × 56.5mm × 17mm (0.082L)
Orange Pi 5Rockchip RK3588S (4x Cortex-A76 @ 2.4GHz + 4x Cortex-A55 @ 1.8GHz)Mali G510 MP48 GB100mm × 62mm × 18mm (0.112L)
BMAX B4Intel N95 (x4 cores Alder-Lake)-16 GB12.5 x 11.2 x 4.4 cm (0.608L)
ℹ️
  • It’s very important to use proper adapter or you will risk the SBC and its performance
  • The Amperes [A] info on adapters is the MAXIMUM they can deliver at a given voltaje [V]
    • The devices will ask for less current if they dont need that much

Testing Results

Synthetic CPU Benchmarks

Sysbench

Results - SysBench 📌
DeviceCPU Benchmark (4 threads)CPU Benchmark (8 threads)
Raspberry Pi 4 2GB~1.7k events-
Raspberry Pi 4 4GB~28k events-
Orange Pi 5~38k events~50k events
AMD 5600G--
sysbench --test=cpu --cpu-max-prime=20000 --num-threads=4 run

7zip

Results - 7ZIP 📌
DeviceTot (4 threads)
Raspberry Pi 4 2GB1622/6311
Raspberry Pi 4 4GB1442/5508
Raspberry Pi 5 8GB2.7k/10k
Orange Pi 52.7k/11.8k
7z b -mmt4

Docker Build Time

Results - Building Docker Image for Trip-Planner 📌
DeviceDocker BuildMax TempPeak Temp (Docker Build)Avg Temp (Docker Build)
Raspberry Pi 4 2GB~3672s-~46°C~39°C
Raspberry Pi 4 4GB~3480s---
Orange Pi 5~1777s80°C~65°C~50°C
BMAX B4~45 seconds64°C fan--
AMD 5600G-- fan--
ℹ️
For some reason, the ARM SBC’s were using just one core during the docker builds (25% and 13%)

The Hetzner x4 SkyLake and 8GB RAM provides similar performance to the BMAX (when used to build the trip-planner container image).

  • Hetzner Shared vCPU (2x Skylake @2ghz) 4GB ~77s
  • Hetzner Shared vCPU (4x Skylake @2ghz) 8GB ~45s

Astral-SH Build Time

Building Astral-SH 📌
Platformopirpi4b 2gbRPi 5 8GBHetzner
Build Time5min 20s10min 7s4min 30s6min 15s

I have to mention that the Alex have way faster internet connection than me - which may influence this result


FAQ

Testing CPU Performance - SysBench, TripPlanner, build Astral-sh,…
#cat /proc/cpuinfo
#uname -a
#nproc
sudo apt install sysbench -y
sysbench --test=cpu --cpu-max-prime=20000 --num-threads=4 run
  • 7zip
sudo apt-get install p7zip-full
7z b -mmt
7z b -mmt4
7z b

and with 7zr:

7zr b -mmt1
git clone https://github.com/JAlcocerT/Py_Trip_Planner/
cd Py_Trip_Planner

sudo bash -c 'time docker pull python:3.8' #let's remove the time of downloading the Python base image from the equation, it was ~1 min!

#docker build -t pytripplanner .
sudo bash -c 'time docker build --no-cache -t pytripplanner .'
#sudo bash -c 'time podman build -t pytripplanner .'
  • Astral-sh Python Dependency Manager:
apt install cargo
#cargo install --git https://github.com/astral-sh/rye rye
time cargo install --git https://github.com/astral-sh/rye rye
  • Just simple stress test:
sudo apt-get install stress-ng

sudo stress --cpu  8 --timeout 120
Testing Internet Connectivity
ip addr show
hostname -I

#sudo apt-get install net-tools
#ifconfig

ping -c 4 192.168.3.1 #gateway
ping 9.9.9.9 #quad9
sudo apt-get install dnsutils -y #dns resolution
nslookup github.com 
dig google.com
sudo apt-get install speedtest-cli
speedtest-cli
curl -sS https://ipinfo.io/json #the command to use
curl -sS http://ip-api.com/json/ #provides info about country, ISP, ...
Measuring Temperature with NetData 📌
version: '3.8'
services:
  netdata:
    container_name: netdata
    image: netdata/netdata:v1.25.0 #https://hub.docker.com/r/netdata/netdata/tags
    ports:
      - '19999:19999'
    volumes:
      - netdataconfig:/etc/netdata
      - netdatalib:/var/lib/netdata
      - netdatacache:/var/cache/netdata
      - '/etc/passwd:/host/etc/passwd:ro'
      - '/etc/group:/host/etc/group:ro'
      - '/proc:/host/proc:ro'
      - '/sys:/host/sys:ro'
      - '/etc/os-release:/host/etc/os-release:ro'
    restart: unless-stopped
    cap_add:
      - SYS_PTRACE
    security_opt:
      - apparmor=unconfined

volumes:
  netdataconfig:
  netdatalib:
  netdatacache:

How to BackUp Properly

Whatever option you choose - make sure to have proper backups setup.

Why? I had to recover Portainer data the hard way…
sudo fdisk -l #get the drive
sudo mkdir /mnt/portainer_backup
sudo mount /dev/nvme0n1p2 /mnt/portainer_backup #mount the drive

#it was installed in the other drive with:
#sudo docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

sudo docker volume create portainer_data
sudo cp -r /mnt/portainer_backup/var/lib/docker/volumes/portainer_data/_data/* /var/lib/docker/volumes/portainer_data/_data/
sudo docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce #now you can re-use your portainer, as it was
Hot to mount external drives consistently
lsblk #list them again
lsblk -f /dev/sda1 /dev/sdb2 #see the format and the UUID of a couple of blocks
df -h /dev/sda1 #you will see if its mounted
sudo apt install ntfs-3g

sudo nano /etc/fstab #forever
UUID=some-uuid /mnt/data_ntfs_500 ntfs-3g defaults,uid=1000,gid=1000,umask=0022 0 1
UUID=some-uuid-of-your-drive /mnt/ext4_mount_point_folder ext4 defaults 0 1

For one time:

sudo mkdir -p /mnt/data_ntfs_500
sudo mount -t ntfs /dev/sda1 /mnt/data_ntfs_500/ #example with ntfs

sudo mkdir -p /mnt/data_ext_2tb
sudo mount -t ext4 /dev/sdb2 /mnt/data_ext_2tb/ #example with ntfs

How to use a RPi - Without a RPi

A raspberry Pi inside a container - https://github.com/ptrsr/pi-ci

A Raspberry Pi emulator in a Docker image that lets developers easily prepare and flash RPi configurations.

Cloud Interesting Resources

https://www.youtube.com/watch?v=jYIgcdIW1yk