简体   繁体   English

在ZeroMQ中进行推拉同步的另一种可靠方法

[英]another reliable way to do PULL-PUSH sync in ZeroMQ

If you're using PUSH sockets, you'll find that the first PULL socket to connect will grab an unfair share of messages. 如果使用的是PUSH套接字,则会发现第一个连接的PULL套接字将捕获不公平的消息共享。 The accurate rotation of messages only happens when all PULL sockets are successfully connected, which can take some milliseconds. 仅当所有PULL套接字都成功连接后,消息的准确轮换才会发生,这可能需要几毫秒的时间。 As an alternative to PUSH/PULL, for lower data rates, consider using ROUTER/DEALER and the load balancing pattern. 作为较低的数据速率的推/拉的替代方法,请考虑使用ROUTER / DEALER和负载平衡模式。

So one way to do sync in PUSH/PULL is using the load balancing pattern. 因此,在PUSH / PULL中进行同步的一种方法是使用负载平衡模式。

For this specific case below, I wonder whether there is another way to do sync: 对于下面的这种特定情况,我想知道是否还有另一种同步方法:

并行流水线

I could set the PULL endpoint in worker to block until the connection successfully setup, and then send a special message via worker's PULL endpoint to 'sink'. 我可以将worker中的PULL端点设置为阻塞,直到成功建立连接为止,然后通过worker的PULL端点向“接收器”发送一条特殊消息。 After 'sink' receives #worker's special messages, 'sink' sends a message with REQ-REP to 'ventilator' to notify that all workers ready. 在“接收器”收到#worker的特殊消息后,“接收器”将带有REQ-REP的消息发送到“通风机”,以通知所有工作人员已准备就绪。 'ventilator' starts to distribute jobs to workers. “通风机”开始将工作分配给工人。 Is it reliable? 它可靠吗?

The picture is from here 图片是从这里

Yes, so long as the Sink knows how many Workers to wait for before telling the Ventilator that it's OK to start sending messages. 是的,只要Sink知道要告诉Ventilator开始发送消息的Ventilator之前要等待的Workers数量。 There's the question of whether the special messages from the Workers get through if they start up before the Sink connects - but you could solve that by having them keep sending their special message until they start getting data from the Ventilator . 存在一个问题,即如果WorkersSink连接之前启动,它们是否会通过特殊消息-但是您可以通过让他们继续发送特殊消息,直到他们开始从Ventilator获取数据来解决这些问题。 If you do this, the Sink would of course simply ignore any duplicates it receives. 如果这样做, Sink当然会忽略接收到的所有重复项。

Of course, that's not quite the same as the Workers having a live, working connection to the Ventilator , but that could itself be sending out special do-nothing messages that the Workers receive. 当然,这与WorkersVentilator存在实时有效的连接并不完全相同,但是它本身可能会发出Workers收到的特殊的不做任何信息。 When they receive one of those that's when they can start sending a special message to the Sink . 当他们收到其中一个时,便可以开始向Sink发送特殊消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM