Hello! I was wondering whether it would be more cost-efficient to run my own Node Red server on a Raspberry Pi or a virtual machine on my laptop. I don't exactly have a spare computer lying around to use as a server, so I figured that buying a Raspberry Pi would be more cost-effective for running a server, since I could also use it for other projects if I wanted to. I'm also kind of scared of somehow messing up my laptop while learning how to use a virtual machine, since I'm new to Linux and what it has to offer. What do you guys think?
It depends on what you end result is that you want to achieve.
Obviously running it on your laptop (which presumably will leave the house with you occasionally) would mean that anything you run on it can not be relied upon to control your house etc. If on the other hand it is just for playing around with and learning - then a virtual machine that is close at hand is easy.
A Rpi will definitely be cheaper to run than a Virtual machine on a laptop - BUT the investment in the RPi, power supply, case, fan, etc etc will end up probably paying for a couple of years of electricity for your laptop
Would the virtual machine perform better than the Raspberry Pi under a high volume of nodes?
Assuming that you have a reasonably specced laptop and can give adequate resources to the VM - then yes easily - but to stress one of the new RPi4 you are going to have to get it to do a LOT of work - so do not let that be a deciding factor
Would it be possible to use the RPi4 for other functions while running the server, in case I wanted to do different projects at the same time?
Yep they are pretty versatile
I'm running Node-RED, Mosquitto, InfluxDB, Grafana, Traccar, Blynk server, zigbee2mqtt, rtl_433 and Portainer running on Docker instances on a Raspberry Pi 4 8GB model. Albeit fhe services have just been configured and the memory usage will likely go up on actual usage, I'm only using 2GB of memory at this point and the system responds are very snappy.
Node-RED is just a small bit of the usage so you don't have to worry about a bit of running other projects at the same time.
Why have you suggested running a VM on the laptop rather than just running it in Windows? I don't use Windows but many do use it with node-red.
On the Pi route if you want to try it with minimum initial expenditure a Pi Zero running Raspbian Lite (so no GUI) will run node-red and mosquitto perfectly well provided you are not looking at thousands of nodes or millisecond response.
Using a VM, as Colin says, is really overkill here. If you really feel the need to keep it separate from the rest of the laptop, I'd advise installing the Windows Subsystem for Linux (WSL) and add the Ubuntu image. This uses a much more lightweight VM platform and in the next release of Windows (arriving as we speak), it is getting ever more closely integrated and more feature complete.
When considering a Pi, you need to think about how much memory it will have. A Pi 4 is a powerful platform but will still be restricted if you only have a gig of memory.
I run 2 Pi's at the moment (a 2 and a 3). They both run many services but neither runs a desktop and both are at capacity, mainly due to me either keeping too much data in InfluxDB or because I run crazy things like the Java-based Ubiquity Wi-Fi controller application along with Node-RED, MQTT, InfluxDB, Telegraf and Grafana.
I now also run an old (not that old but a few years old) Lenovo Thinkpad x240 (8GB RAM, 512G HDD) as my new server platform and I'll be retiring the Pi's for their current use (they will probably pop up again in the future of course for some other purpose). Running the laptop in power saving mode without a desktop running keeps the power consumption well below 20w, maybe as low as 12w - certainly low enough not to worry about cost and also not to trigger the fans. This is faster and more reliable over all than a Pi because I'm not running of an SD-Card and I have a built-in battery backup Of course, not everyone has such things lying around.
Anyway, bottom line:
- You don't need Linux to run Node-RED
- Use something separate to your laptop if you want it running all the time
- Even a Pi2 can do a LOT.
Thank you all for your replies! I've decided that a Raspberry Pi 4 is the device I would like to use for now, since its still very versatile and can run separately from my laptop!