yaroslav-gwit / HosterCore

🚀 Hoster: Empowering FreeBSD Virtualisation with Ease
https://docs.hoster-core.gateway-it.com/
Apache License 2.0
41 stars 0 forks source link

Implement basic caching on the Hoster nodes #121

Open yaroslav-gwit opened 4 months ago

yaroslav-gwit commented 4 months ago

The WebUI work pushes HosterCore to the new horizons. I need to implement a basic caching for the VMs, Jails, and Snapshots, because scanning the file system during every API call is not very efficient, and sometimes outright slow (it takes ~200+ ms to get a list of snaps, and it looks a bit "jumpy" in the UI).

I'll expose the cached resources as a separate endpoint, in case someone (or me) would need more control over the caching behaviour on the client side.

This implementation will also allow me to "poll" for the list of VMs and Jails in the background every 5-7 seconds (using very few server resources), to update their status if it changes (e.g. if the VM has crashed or was stopped, it's status needs to be switched to "stopped" within the list of VMs). Check the screenshots to get more info.

image image

yaroslav-gwit commented 2 months ago

VM cache function is ready, but might've not been propagated to every higher level functions that may need to call the "cache update". Same goes for snapshots.

The only cache that's left at this point is Jails cache.