help icon indicating copy to clipboard operation
help copied to clipboard

Hello world take so many memory

Open batobolg opened this issue 10 years ago • 2 comments

  • Version:v4.4.7
  • Platform: Linux ainode06 3.10.0-327.10.1.el7.x86_64 #1 SMP Tue Feb 16 17:03:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: CentOS 7

[bato@ainode06 nodejs]$ ./node-v4.4.7-linux-x64/bin/node -v v4.4.7


my server.js is


[bato@ainode06 node-v4.4.7-linux-x64]$ cat server.js

const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

and after use ab command bench the nodejs memory like this


[bato@ainode06 ~]$ ps u

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
bato      6150  0.0  0.0 151024  1780 pts/2    R+   15:06   0:00 ps u
bato     17496  0.0  0.0 115472  2248 pts/1    Ss   13:48   0:00 -bash
bato     19341 12.2  0.1 913832 60144 pts/1    Sl+  13:54   8:45 bin/node server.js

i don't know why node js take 60144kb memory just for hello world program. any information ?

batobolg avatar Jul 13 '16 07:07 batobolg

Here's what I'm getting from the same code, but diff system:

screen shot 2016-07-13 at 1 42 47 pm


But Let me check, if i can help you with yours

Knighton910 avatar Jul 13 '16 20:07 Knighton910

click me 🔗

this article is touches on some problems with cent os & nodejs in development mode, but really is going in detail about the two in hosting & deploying -- specifically --

""" Just like on your development machine you can run node app.js on your server and your code will be executed perfectly.

However, this is far from ideal and there are many problems with it. Let’s look at just a few of them.

Serving static files, like JavaScript, images & CSS, can be done with node but it is not very efficient. It will use too much memory and it might not cache frequently accessed files, which in result can make your Node app slow or even crash it. """


click me 🔗

The Installing Node.js via package manager page has a nice page with specific sections about CENT OS


[personal opinion]

I think from what i searched is, there isn't a plethora amount of nodejs & cent os experience going on but i'm sure you will find enough to get by to fix your problems.

Knighton910 avatar Jul 13 '16 21:07 Knighton910