如何启动新的nodejs进程

发布于 2024-10-07 13:24:59 字数 352 浏览 0 评论 0原文

我正在编写一个 Nodejs 守护进程,用于在后台连接 Twitter、Facebook 和其他社交网络。每个用户都可以有多个社交网络连接到其帐户。假设每个用户都连接了大约 5 个网络并且有 1000 个用户。那将是 5000 个连接。连接必须接近实时,比如大约 1 分钟之类的。

我的想法是为每个新用户启动一个新的 Nodejs 进程,从这些社交网络中提取内容,而不是从每个用户中提取每个数据的 1 个进程。 但我的问题是如何开始。我已经编写了一些脚本来执行此操作,但由于我对 Nodejs 的了解还不够专业,所以我不知道这是如何工作的。

有没有办法在新用户注册时自动启动新的nodejs进程?或者有更好的方法来做到这一点吗?

提前致谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼睛会笑 2024-10-14 13:24:59

你想要 1k 个进程吗?这已经带来了高达 1gig 的开销以及操作系统的大量工作。

为什么不将所有内容都放在一个 Node.js 进程中呢?你真的测试过吗?您确定需要多个进程吗?如果您愿意,可以使用 child_process 模块从 Node 内启动新的子进程.js。

为了保持主进程运行,你应该看看永远。

尽管如此,我还是想说先用一个进程对其进行测试,然后如果您发现它没有按照您的预期执行/工作,那么将这些内容放入多个进程中应该是微不足道的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文