Performance issues on Pi4

I have been experiencing severe performance issues with homeassistant on my Pi4 4GB since a while now. It mostly manifests in several seconds of loading time when reloading the homepage and when turning on lights via automation. Im also experiencing random disconnects which cause a page reload.

As a first step I upgraded my SanDisk Extreme A2 Micro SD card to an Intenso SSD.

I did install glances but everything looks kind of ok.

If you have any ideas what I can try feel free to share.

Cameras? Backups? AI?

What integrations you using?

Possibly time to upgrade to a more power type device instead of a PI?

1 Like

Here are some more informations about my setup:
I do not have any camera or AI services running.

Most of my sensors are integrated via Z2M.

Here is a list of all my Integrations, add-ons and HACS frontend modifications:

Integrations:
  • Adaptive Beleuchtung
  • Android Debug Bridge
  • Average Sensor
  • Backup
  • Battery Notes
  • Better Thermostat
  • Bluetooth
  • Brother Printer
  • Deutscher Wetterdienst (DWD) Weather Warnings
  • DLNA Digital Media Renderer
  • DLNA Digital Media Server
  • Einkaufsliste
  • Electricity Maps
  • ESPHome
  • FRITZ!Box Tools
  • FRITZ!SmartHome
  • Google Calendar
  • Google Cast
  • HACS
  • HASS.Agent
  • Home Assistant Supervisor
  • HomeKit Device
  • iBeacon Tracker
  • Internet Printing Protocol (IPP)
  • IP Ban Allowlist
  • Lokales To-do
  • Meteorologisk institutt (Met.no)
  • Mobile-App
  • MQTT
  • Node-RED Companion
  • OctoPrint
  • Open-Meteo
  • Open-Meteo Solar Forecast
  • Oral-B
  • Pi-hole V6 Integration
  • Ping (ICMP)
  • Powercalc
  • Proximität
  • Raspberry Pi StromversorgungsprĂĽfer
  • Scheduler
  • Shelly
  • Simple Icons
  • Sonne
  • Spook
  • Tasmota
  • Tuya
  • Einrichtungsfehler
  • Unraid API
  • UPnP/IGD
  • Volkswagen Connect
  • Waste Collection Schedule
  • Watchman
  • WLED
Add-Ons
  • Advanced SSH & Web Terminal
  • (Duck DNS)
  • ESPHome Device Builder
  • (FTP)
  • Glances
  • ha-sip
  • Home Assistant Google Drive Backup
  • Mosquitto broker
  • Node-RED
  • (SQLite Web)
  • Studio Code Server
  • TasmoAdmin
  • Zigbee2MQTT
    Brackets around an add-on indicate stopped status unless needed
HACS dashboard
  • Mushroom
  • mini-graph-card
  • Bubble Card
  • apexcharts-card
  • layout-card
  • Scheduler Card
  • Battery State Card / Entity Row
  • Power Flow Card Plus
  • Simple Thermostat
  • Horizon Card
  • Home Assistant Swipe Navigation
  • Bar Card
  • Weather Chart Card
  • expander-card
  • Hourly Weather Card
  • TrashCard
  • Swipe Card
  • Weather Radar Card
  • Vehicle Status Card
  • Tabbed Card
  • BHA Icon Pack
  • Custom-ui
  • My Cards Bundle
  • custom-icons
  • Background Graph Entities
  • YTZ Icon Pack
    Not all are in active use
HACS integrations
  • HACS
  • Adaptive Lighting
  • Tuya Local
  • Waste Collection Schedule
  • Powercalc
  • Better Thermostat
  • Spook :ghost: Your homie
  • Battery Notes
  • Scheduler component
  • Watchman
  • Node-RED Companion
  • Volkswagen Connect
  • Pi-hole V6 Integration
  • Average Sensor
  • simpleicons
  • HASS.Agent
  • Custom Icons
  • Tuya BLE
  • IP Ban Allowlist

I have in total 17 automations and 6 Node Red flows which I want to replace with automations.
In total I have 243 devices with 2097 (1317 active) entities.

I think the Pi should be more than enough especially considering it is essentially the same hardware as the Home Assistant Yellow wich is faster than the Home Assistant Green, the only two devices sold by Nabu Casa for the sole purpose of running home assistant on them.

You have all that running on a PI4 and you are complaining about performance?
I’m shocked it works at all.

Just running on recommended hardware. No wonder its not working. Duhhh

Easiest

most convenient

Popular

That is how those devices are described.
Recommended it is not.

There is no recommended hardware that I know of. RasPi and all variants are considered minimum requirements to get started.

There is the official installation Type reference that recommends the Pi 4 or Pi 5 with 2GB+ RAM Installation - Home Assistant and there is the fact that the official Hardware uses a compute module 4 or even less powerful hardware.

Goal of the HA hardware is provide cheap entry level hardware. It works ok for simple installs but people quickly outgrow if they do more advanced install.

Your swap file is being used, to 53%, which probably indicates significant memory paging is taking place. Memory page thrashing is always going to lead to long pauses in program execution (and disc wear).

When paging is taking place, both disc and CPU activity is focused on that. With several add-ons that may be partially used, memory pages are possibly being swapped out then required again on an alternating intermittent basis.

This is not necessarily a case of having too much in memory, but rather having stuff that is not used and has a high swapiness factor, so the pager moves it to swap, then it is required again later, having to be swapped back in.

Looking closely, the used memory is 1.8G, which is about half of available, being a typically balanced approach taken in memory management. HA, as the top process, is using 2.0G, which to me suggests that HA itself is being actively paged, which maybe is the primary reason for poor performance. Constant thrashing.

Running glances on my own, Odroid n2 machine (HA Blue) I note that I have the same basic memory size as you. 4GB total, 3.7GB available, 1.8 used. The only real difference is that I have 6 core, utilised at 0.2, Home Assistant process is CPU 16% and 1.6G memory, and my swap file is almost empty. No swapping, and HA is not overloading a core [but then, I don’t do very much on my HA].

You could try tinkering with swapiness, or even turn the swap off, but 50% free memory and a slightly-used swap file is preferred to running out of memory when large buffers are called for.

Adding memory is not always physically possible, so perhaps it is time to upgrade to a Pi5 with 8GB.

Well this is most likely not a that bad recommendation for an easy start / beginners. It will run HA and some addons without a problem. And will be enough for most users.

But if you’re advanced enough and want to run a lot addons (which means running multiple maybe ram intensive containers on the same hardware) you should be able to do the maths how much ram you need most likely.

I guess there would be more complaints about this guide if they would recommend a top notch NUC and 32GB+ ram for everyone. :stuck_out_tongue: