Node.js with socket.io and firmata on raspbian (model B) runs slow
-
21-12-2019 - |
Question
I´m running a Raspberry Pi Model B (512MB RAM) with a 16 gB 300MB/s SD-card and recent raspbian with all updates.
On this machine I´ve set up a apache2-server, node.js with socket.io and firmata.
Within my web-application, video streaming is a key feature.
When I access my webserver just for streaming the videos (without node/socket.io/firmata), everything streams with a good performance. But when I switch on node.js/socket.io/firmata it's rather slow, it takes 5-7 seconds to start streaming the videos.
I had problems installing node.js in the first place. Node.js from source compiled/installed like a charm, but when I tried to run it, I got this mysterious "Illegal instruction" message.
As an alternative I took the precompiled debian-packages and installed them using dpkg using this repo:
http://revryl.com/2014/01/04/nodejs-raspberry-pi/
They say that nodejs will run slower, but that´s not acceptable for me.
Any hints?
Thanks and regards!
Solution
Allright, it´s faster now. For everyone with this issue:
- Dispose apache2 and use lighttpd instead. Just check out this page and see why: http://www.jeremymorgan.com/blog/programming/raspberry-pi-web-server-comparison/
- Start node.js via script and put into /etc/rc.local Out of some reason it uses much less RAM and CPU when in idle.
- Try to avoid firmata. If you need to control hardware that requires simple wiring, try to use the "pi-gpio". It´s MUCH faster and uses less resources. Also you don´t need your arduino anymore as you can use only the rpi.