Go Down

Topic: Node.js for the YUN (Read 4870 times) previous topic - next topic

Federico Fissore

One more thing. As you know nodejs is single threaded. In your example, that means that it's either giving you back the glaphicons or it's answering some "hello world" request. Uglify and pack all the assets in few files (ideally: one js and one css)
Have you upgraded the Yún? If you've just got it, then it needs to be upgraded! Check out the tutorial

mantissa00

@Squonk42
I have a fresh install on a new yun with a smaller sd card (2GB instead of 8GB), and I had that issue.

here the df logs:

------------------ BIG SD CARD - NO PROBLEM ------------------
Code: [Select]


root@Arduino:~# cat /usr/bin/node
#!/bin/sh

NODE_PATH=/usr/lib/node_modules /usr/bin/nodejs --stack_size=1024 --max_old_space_size=20 --max_new_space_size=2048 --max_executable_size=5 --gc_global --gc_interval=100 $@


root@Arduino:~# df -h

Filesystem                Size      Used Available Use% Mounted on
rootfs                    6.5G    325.3M      5.9G   5% /
/dev/root                 7.5M      7.5M         0 100% /rom
tmpfs                    29.8M    164.0K     29.7M   1% /tmp
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda2                 6.5G    325.3M      5.9G   5% /overlay
overlayfs:/overlay        6.5G    325.3M      5.9G   5% /
/dev/sda1               898.2M     12.0K    898.2M   0% /mnt/sda1


root@Arduino:~#


------------------ SMALL SD CARD - PROBLEM ------------------
Code: [Select]


root@Arduino2:~/repo/node# cat /usr/bin/node
#!/bin/sh

#NODE_PATH=/usr/lib/node_modules /usr/bin/nodejs --stack_size=1024 --max_old_space_size=20 --max_new_space_size=2048 --max_executable_size=5 --gc_global --gc_interval=100 $@
NODE_PATH=/usr/lib/node_modules /usr/bin/nodejs $@


root@Arduino2:~/repo/node# df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                    1.0G     81.7M    909.6M   8% /
/dev/root                 7.5M      7.5M         0 100% /rom
tmpfs                    29.8M    152.0K     29.7M   0% /tmp
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda2                 1.0G     81.7M    909.6M   8% /overlay
overlayfs:/overlay        1.0G     81.7M    909.6M   8% /
/dev/sda1               898.2M     12.0K    898.2M   0% /mnt/sda1


root@Arduino2:~/repo/node#


(is free logs also needed?)

mantissa00

I'm using express (with body-parser sub-module) for rest request,
ejs as renderer,
sqlite3 as db and dblite ( https://github.com/WebReflection/dblite ) as node module for controlling it
then my setup is like your: bootstrap and jquery used in the front end for layout, glyph icons and ajax.

Squonk42

@mantissa00: I have a 16 GB class 4 SD card with only 3% used, so this is not the problem.

The problem is more with CPU performance and RAM usage:
root@Arduino:~/node/foo# ./bin/www 
GET /contact 304 16238ms
GET /stylesheets/bootstrap.min.css 304 151ms
GET /javascripts/jquery-1.11.1.min.js 304 134ms
GET /stylesheets/style.css 304 135ms
GET /javascripts/bootstrap.min.js 304 131ms
POST /thanks 200 2873ms - 1.21kb
GET /stylesheets/bootstrap.min.css 304 63ms
GET /javascripts/jquery-1.11.1.min.js 304 60ms
GET /stylesheets/style.css 304 58ms
GET /javascripts/bootstrap.min.js 304 70ms
GET / 304 5007ms
GET /stylesheets/bootstrap.min.css 304 43ms
GET /javascripts/jquery-1.11.1.min.js 304 43ms
GET /stylesheets/style.css 304 45ms
GET /javascripts/bootstrap.min.js 304 49ms
GET /fonts/glyphicons-halflings-regular.woff 304 24ms
GET /about 304 4519ms
GET /stylesheets/bootstrap.min.css 304 43ms
GET /javascripts/jquery-1.11.1.min.js 304 45ms
GET /stylesheets/style.css 304 47ms
GET /javascripts/bootstrap.min.js 304 48ms
GET /contact 304 3426ms
GET /stylesheets/bootstrap.min.css 304 58ms
GET /javascripts/jquery-1.11.1.min.js 304 61ms
GET /stylesheets/style.css 304 62ms
GET /javascripts/bootstrap.min.js 304 65ms
GET / 304 3072ms
GET /stylesheets/bootstrap.min.css 304 30ms
GET /stylesheets/style.css 304 45ms
GET /javascripts/jquery-1.11.1.min.js 304 46ms
GET /javascripts/bootstrap.min.js 304 40ms
GET /fonts/glyphicons-halflings-regular.woff 304 19ms

And when using the memory limit options in "/usr/bin/node", I get an "process out of memory" very quickly...

So I guess that a full-stack Node.js is just too much for the Yun, and that all that can be done are only very simple scripts.

But then, what is the point in using Node.js, then? Besides the "all-JS" advantage, why not use Python Tornado or Nginx/Lua-based OpenResty in this case?

Please note that I am novice to Node.js and that I like its overall philosophy. But I am also trying to be pragmatic and find the best solution for developing web applications on the Yun. As such, I am asking eagerly for advises and experience from other users!

sonnyyu


...
And when using the memory limit options in "/usr/bin/node", I get an "process out of memory" very quickly...

So I guess that a full-stack Node.js is just too much for the Yun, and that all that can be done are only very simple scripts.
...


I am not surprise, since the heart of Yún's CPU - AR9331 is already on bottom of the food chain.


FYI;-

The heart of Yún is CPU - AR9331, here is the market position of it.

AR9331 (MIPS 24k@400MHz, 1x1:1, 150Mbs/2.4GHz, PHY/100Mbs)

AR9341 (MIPS 74Kc@500Mhz, 2x2:2, 300Mbs/2.4GHz, PHY/100Mbs)

AR9344 (MIPS 74Kc@600MHz, 2x2:2, 300Mbs/2.4GHz, 450Mbs/5GHz, PHY/1Gbs)

QCA9558 (MIPS 74Kc@720MHz, 3x3, 450Mbs/2.4GHz, 1300Mbs/5GHz, PHY/1Gbs)

It is already on bottom of the food chain.



Go Up