3

I just got my raspberry pi and i'm experimenting node.js on it. Specifically I'm making a web server to serve my own node.js web site. I'm a little puzzled by the process logs though. When i run my node app, a single node process is started as normal, no surprises: http://screencast.com/t/8SQY3qDvxkK

Now when I visited the page, i see my process logs CPU spike up to 100% and 4 other node.js process is spawned. Very strange behavior. http://screencast.com/t/ushqLDINxYV

The web page i'm requesting is just a simple html with a few divs and loading a bunch of javascript / css assets like jQuery, bootstrap.

I attached my html for those who are keen to replicate.

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Hello World</title>
    <meta charset="utf_8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300">
    <link rel="stylesheet" href="/lib/bootstrap-3.0.0rc1/css/bootstrap.min.css">
    <link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.css">
    <link rel="stylesheet" href="/css/style.css">
  </head>
  <body style="zoom:1;">
    <div class="container-fluid">
      <div class="logo">
      </div>
      <nav>
        <ul class="menu nav">
          <li><a href="#"><i class="icon-home"></i></a></li>
          <li><a href="#"><i class="icon-user"></i></a></li>
          <li><a href="#"><i class="icon-th"></i></a></li>
          <li><a href="#"><i class="icon-envelope"></i></a></li>
        </ul>
      </nav>
    </div>
    <script src="/lib/jquery-1.9.1.min.js"></script>
    <script src="/lib/bootstrap-3.0.0rc1/js/bootstrap.min.js"></script>
  </body>
</html>

Anyone has any clue why this is happening? This does not happen if the my server is simply sending a response message like "res.send('hi there')" instead of rendering html "res.render("hello.jade")"

3

your browser is requesting your scripts while reading main .html file, hence the other 4 new processes (note, request to fonts.google.com does not result in the new process started). it's a typical behaviour, you should not be worried about that.

  • Thank you for the clarification! But I do realize that the pi is serving the page rather slowly. Give it a shot! missile.io – Shawn Lim Aug 5 '13 at 5:47
  • 1
    Node is not like apache, which creates a new process for every request. Node is single threaded by design. So, as far as I know, shouldn't do that. Also note the fact that memory usage by all processes is exactly the same. I thinks they are just threads created by node to read the files from the filesystem. Since file reading is blocking, and Node doesn't like being blocked. – Gerben Aug 5 '13 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.