0

I have a node application that uses Socket.IO for the messaging.

And I run it using

node --expose_gc /path/to/app.js

Now, when I check on the htop utility, I noticed that instead of 1, I am getting multiple processes of the same command.

Attachment

Can someone, in noob terms, explain to me why and what is going on here? I'm also worried that it may consume unexpected memory/cpu usage too.

Aldee
  • 4,439
  • 10
  • 48
  • 71

2 Answers2

1

socket.io does not fork or spawn any child processes. usually sub processes that run node.js are spawned via cluster module but socket.io does no such thing. it just adds a handler on top of a http server.

sagie
  • 1,744
  • 14
  • 15
1

socket.io is just a library that hooks into a web server and listens for certain incoming requests (those requests that initiate a webSocket/socket.io connection). Once a socket.io connection is initiated, it just uses normal socket programming to send/receive messages.

It does not start up any additional processes by itself.

Your multiple processes are either because you accidentally started your own app multiple times without shutting it down or there is something else in your app that is starting up multiple processes. socket.io does not do that.

jfriend00
  • 683,504
  • 96
  • 985
  • 979