简体   繁体   English

Zmq随机接收和回复

[英]Zmq for random recv and reply

I have two question regarding Zmq:- 关于Zmq,我有两个问题:

1) I am implementing a server which would receive 10K requests/per minute and then redirect these request towards backend. 1)我正在实现一个服务器,该服务器每分钟将接收10K个请求,然后将这些请求重定向到后端。 After getting response from backend it will then send response back. 从后端获取响应后,它将发送回响应。 I can't use request/reply as restriction in this pattern is recv/reply should be synchronous. 我不能使用request / reply,因为这种模式的限制是recv / reply应该是同步的。 Can anyone suggest me as what to use in this scenario. 谁能建议我在这种情况下使用什么。

2) Do I need to implement multi-threading in this also. 2)我是否还需要在其中实现多线程。

Thanks in advance. 提前致谢。

Let me answer first the Q1 - requirement on performance & Q2 - if there is a need for multithreading: 如果需要多线程,首先让我回答问题1-性能要求和问题2

What are ZeroMQ transport overhead times about? ZeroMQ传输开销时间大约是多少?

From trivial performance tests, intentionally adding a TCP-transport wrapping overhead, you may taste the "cost" of ZeroMQ message handling layer in [usec] per a message sent. 通过琐碎的性能测试,有意地添加了TCP传输包装开销,您可能会发现[usec]每发送一条消息,就会发现ZeroMQ消息处理层的“成本”。

                         21.936  [usec]/MSG
                        111.280  [usec]/MSG
                         39.714  [usec]/MSG
                         37.080  [usec]/MSG
                         11.351  [usec]/MSG

To have an idea about a message batch size impact relief, lets read retest with growin size 要了解有关邮件批量大小减轻影响的想法,请让我们阅读带有增长大小的重新测试

>>> [ sender( nBatchSIZE = x ) for x in ( 1, 10, 100, 1000, 10000, 100000, 1000000 ) ]

sent       1 ... RUN took:       58  [usec] i.e.  58.0  [usec]/MSG
sent      10 ... RUN took:      156  [usec] i.e.  15.6  [usec]/MSG
sent     100 ... RUN took:     1071  [usec] i.e.  10.7  [usec]/MSG
sent    1000 ... RUN took:    10561  [usec] i.e.  10.5  [usec]/MSG
sent   10000 ... RUN took:   106478  [usec] i.e.  10.6  [usec]/MSG
sent  100000 ... RUN took:  1333242  [usec] i.e.  13.3  [usec]/MSG

Based on these figures, your Q1 the system will have no problem with 10k/min stream of events on reasonable sized MSGs ( not mentioning multi-GB BLOBs ) 根据这些数据,您的Q1系统在合理大小的MSG上不会出现10k / min的事件流问题(更不用说多GB BLOB了)

The processing performance is thus limited by the back-end phase 因此,处理性能受到后端阶段的限制

Suggestion on Q2-what to use : 关于第二季度使用建议:

The REQ/REP thus goes out of the table. 因此, REQ/REP不在表格中。 Rather than multithreading thus try to consider any performance scale-able approaches to increase your end-to-end processing capability -- using more advanced schemes for load-balancers alike REQ/ROUTER||ROUTER/REQ et al, you may both increase the processing speed and add some failure resolution features. 与其尝试使用任何性能可扩展的方法来提高端到端处理能力,不如使用多线程,而是使用更高级的负载均衡器方案,例如REQ/ROUTER||ROUTER/REQ等,都可以提高性能。处理速度并添加一些故障解决功能。 Check sample trivialised structures in Single- & Multi-Cluster Architectures 检查单集群和多集群体系结构中的样本琐碎结构

For your message volume, it's all about message size. 对于您的消息量,这完全取决于消息的大小。 Assuming a roughly "typical" message size (say up to several hundred bytes would be typical) and a system that can otherwise handle that throughput (eg if you were to preload your messages rather than receive them with ZMQ, would it process your message volume efficiently enough?), then you won't break a sweat with 10k messages/minute. 假设消息大小大致为“典型”(例如,通常多达几百个字节),并且该系统可以处理该吞吐量(例如,如果要预加载消息而不是通过ZMQ接收消息,它将处理您的消息量)效率足够高?),那么您就不会每分钟发送10k消息就大汗淋漓。 You could probably do that each second (as you can see in the other answer). 您可能每秒都可以这样做(如您在其他答案中所见)。

ZMQ will support whatever message pattern you're looking for, but you'll have to provide more information to determine what pattern would be optimal for you. ZMQ将支持您想要的任何消息模式,但是您必须提供更多信息来确定哪种模式最适合您。 There are a lot of good examples in the guide . 有很多的很好的例子引导

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

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