gpt4 book ai didi

performance - NodeJS|Cluster process.send 和 worker.send 是否阻塞?如果有,表现如何?

转载 作者:搜寻专家 更新时间:2023-10-31 23:27:53 25 4
gpt4 key购买 nike

我有 2 个问题。

  1. process.send 和 worker.send 函数是否阻塞?这种进程间通信的性能如何?

  2. 我有一个集群,其中主 Node 将更新推送给工作 Node ,工作 Node 将聚合数据推送给主 Node 。但是,有一个特定的查询,我需要从 master 获取最新数据。当请求进入 worker 时,我存储“响应”对象,然后执行 process.send() 以联系 master 获取最新数据,然后在 master 上,我获取数据然后执行 worker.send () 返回数据。我来回传递一个 responseId,以便当请求最终返回时,我知道要写回哪个响应,然后对其调用 end() 函数。

有没有更好的方法在进程之间进行这样的同步调用?它不会经常发生,但是对于正在发生的所有其他非阻塞请求,这种情况会产生什么样的性能影响?它会支撑其他一切吗?这是最有效的方法吗?

最佳答案

Are the process.send and worker.send functions blocking

没有。

And what is the performance of this type of inter-process communication

大部分与JSON序列化/反序列化相同。数据传输由操作系统处理,速度非常快。

Is there a better way to do synchronous calls like this between processes?

不在 Node 中。

It doesn't happen very often, but what kind of performance implications will come from this with regard to all the other non-blocking requests that are happening

不重要。就像查询数据库一样……当数据库运行并完成其工作时,Web 进程可以自由响应其他请求。这里是同一个校长(主人 -> worker )。

关于performance - NodeJS|Cluster process.send 和 worker.send 是否阻塞?如果有,表现如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10890689/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com