Reputation: 911
I'm writing a nodejs daemon for connecting in the background to Twitter, Facebook and other social networks. Every user can have multiple social networks connected to it's account. And say, when every user has somewhere around 5 networks connected and there are 1000 users. That would be 5000 connections. The connections have to be near realtime, like somewhere around 1 minute or something.
My idea was to start a new nodejs process for every new user that pulls in the content from those social networks instead of 1 process that pulls in every data from every user. But my question is how to start. I allready wrote some of the script to do this, but since my knowledge of nodejs is nowhere near professional I don't know how this works.
Is there a way to automatically start a new nodejs process when a new user registers? Or is there a better way to do this?
Thanks in advance.
Upvotes: 2
Views: 1182
Reputation: 46745
You want 1k processes? That's already up to 1gig overhead and a ton of work the OS.
Why not have all inside one Node.js process? Have you actually tested it? Are you sure you need multiple processes? If you want you can use the child_process module to start new child processes from within Node.js.
For keeping the main process running you should take a look at forever.
Still I would say test it with one process first, and then if you see that it doesn't perform/work as you expected it to, it should be trivial to put the stuff into multiple processes.
Upvotes: 1