A few weeks ago I migrated my HA to an intel nuc (quad core celeron j3455)
I’m running the hass.io docker image on an VM with Ubuntu Server. The VM has assigned 4 cores and 2GB of RAM. I run the hassio addons: mosquitto, mariadb and dassio.
I can’t get anything better than 50-60 seconts restart time, even disabling discovery and using mariadb instead of sqlite.
Once running, cpu usage is around 4%
Any ideas of howto improve this start / restart time?
I have 8GB of (actual) RAM in my system and my reboots are less than 30 seconds. But I do find that some components take longer than others. The z-wave can take a little longer to come up, but I suspect that’s more to do with my devices than Home Assistant. This is just with the HASSIO image for Intel NUC, using MariaDB. Not a VM. But I did play around with a virtual environment on debian before settling on this setup and it was also quick that way.
More RAM would probably help. If you don’t want to invest in more real RAM, then I suppose a RAM Drive should do the trick since you have an SSD already.
Also, have you looked through the System log to see if something is showing errors?
Is it 60 seconds until you’re able to login through the frontend interface? Or 60 seconds before every component has finished loading?
I have increased the assigned RAM to the VM: from 2GB to 4GB, and I got the same 50-60 seconds mark.
Once system is loaded and running, free ram is stable (Ubuntu+hassio+the other docker images use only 800MB).
There aren’t errors on System log during boot. It is 50-60 seconds between pressing “Restart HA” button on web interface, and receiving a notification with an automation once HA reloads (that is, web interface is avaliable to login and shows all devices and its states).
I’ll increase logging level to record the time that every component needs to start.
I guess that HA startup is fully sequential, making it so slow.
BTW what is your OS setup with the intel NUC? And what NUC model are you using?
Exclude unused platforms from discovery you don’t want to use; or disable discovery all together
Put your database/sqlite file on something fast as it seems to get parsed at startup for some reason. Also set a reasonable retention time. I personally keep the sqlite file on a Ramdisk with a 7 day purge interval and don’t care if I loose it on a reboot - this has helped speed tremendously.
Turn down the zwave logging level as by default it is really verbose
Right now you also have a couple levels of abstraction going on, Ubuntu running on a hypervisor; and in that Ubuntu guest hass.io as a docker; which itself runs images as dockers… A pretty deep habit hole
Try running the HA docker on the Ubuntu guest - no hass.io – as a test; you may find a significant difference.
I believe it’s built on ResinOS, which has some limitations. For example, the bluetooth on the NUC is inaccessible.
My system is the lowest spec celeron current-generation Intel NUC (BOXNUC6CAYH). But it’s still plenty quick.
If you suspect your database is slowing things down, as foraster is suggesting, I believe you can comment-out the “recorder:” to run without that. Might be a quick test to see if that’s a significant factor. I have mine set to purge every day, keeping just 7 days of data. Also, I’ve excluded any entities and domains that I don’t need historical data for.
@jwelter please see results above. BTW the database is running on mariadb. I don’t have zwave devices.
Regarding the different levels of virtualization, I choose to use the docker way, over a supported OS (Ubuntu), because in the past I suffered version upgrades on armbian and derivatives. The docker ecosystem that hass.io offers has given me quite good results (except this start time), but gives you the management of add-ons and also the snapshots.
Additionally, using a hypervisor lets me take periodic snapshots and if I ever to recover from a disaster, I will just repair the hardware, deploy the VM and restart it.
Can you point me to the HA docker please? With this setup I guess I’ll have to manually setup the other docker images that hassio currently manages.
@new_west_geek we are using the same NUC! Test results below:
After disabling discovery, history and logger sections, I only got a 50-55s HA of restart time. So there seems to be no big difference (5 seconds at most)
Later I have disabled completely logbook and recorder: that gave me a gain of 5 seconds: I’ll keep it enabled, because I want to maintain the history at least for 24 hours.
I finally managed to identify the time that every platform (or domain) needs to setup: I have changed logging level to debug and analyzed the homeassistant.log file.
I have found that some platforms that I don’t use (like tts) took 6-8 seconds to start.
Acording to debug logs, other “domains” took more time:
domain setup: 12.9 seconds
domain sensor: 12.3 seconds
domain mediaplayer: 14.0 seconds
domain device_tracker: 17.6 seconds
So here is where the system is spending most of the time (most of the domains or platforms take less than 2 seconds).
I’ll keep making some tests with the different platforms, but I don’t know if there is a “fine tuning” to optimize this.
I was able to improve startup speed on a rpi3b dramatically by removing default components that I don’t use. eg:
cloud, tts, discovery, conversation, automation (I am only using automation_old). I also set my db to purge after 7 days and only included components i really needed. The above seemed to help.