26

Would like to know is node.js with V8 engine suitable to be deployed on limited memory device (e.g. 256mb) and running in parallel with other process.

I read that it will hook up the resource of the machine. Is there way to limit the memory and processing usage of V8 engine itself?

TonyTakeshi
  • 5,869
  • 10
  • 51
  • 72

3 Answers3

21

256 MB is sufficient amount of RAM to run Node.js (e.g. on Linux VPS instance), assuming no other memory-hog software is run. Node has --max-stack-size argument for limiting the memory usage.

Node's single-thread evented server model generally makes efficient use of resources, but V8 due its JIT architecture is likely to use somewhat more memory than interpreted/bytecompiled implementations, such as PHP or CPython (while offering superior performance). Also, to take advantage of multiple CPU cores, multiple Node.js processes must be run (versus memory-sharing threads), effectively multiplying the memory usage, but this limitation applies to its most popular competitors as well.

In the respect of "running in parallel with other process" or "hooking up the resource of the machine", there is nothing special about running Node.js process (except the not uncommon multicore issue); it behaves similarly to any userland program. You can low-prioritize the Node.js process in OS level (e.g. with nice), but depending on your device/application, I/O can be potentially more an issue.

Purely from technical/effectiviness perspective, Erlang is probably more ideal choice for a high-level language when true multiprocessing support and high concurrency is required.

jholster
  • 5,066
  • 1
  • 27
  • 20
15

64MB of RAM is sufficient for V8 and Node.js

See "Compiling Node.js for Arduino YÚN" and also "installing Node.js on Arduino YÚN".

Arduino YÚN runs linux with 64MB of RAM.

Matteo T.
  • 1,278
  • 11
  • 13
  • "full-stack Node.js is just too much for the Yun, and that all that can be done are only very simple scripts" see http://forum.arduino.cc/index.php?topic=193765.15 – nkint Jun 16 '14 at 22:16
  • 7
    Sure, on such a device you are very limited, but that "only very simple scripts" is very relative too. In my experiment, a TL-MR3020 with half the RAM of YÚN, is doing the following: * serving an HTML5 web application; * receiving JSON messages on WebSocket Secure every 200ms; * sending JSON messages on WebSocket Secure every 50ms; * sending and receiving JSON messages on UDP every 40ms; * logging operations on text file. All that works very fine with 2 or 3 clients, then it becomes a little slower with the messages. – Matteo T. Jun 16 '14 at 22:34
  • 1
    @MatteoT. would you have a link/guide on how you set Node.js on that device; is it using OpenWRT? – Daniel Sokolowski Jul 30 '14 at 17:42
  • I downloaded the packages built by the Arduino YUN Community and installed them on OpenWRT. I also used a USB flash drive to expand the memory of my router – Matteo T. Jul 31 '14 at 18:28
6

The BeagleBone has 256MB RAM (and in a normal configuration, no virtual memory), and it runs node.js quite nicely.

Daniel Chisholm
  • 566
  • 5
  • 16