最佳答案
每个人都控制其他一些事情:
ZMQ_SNDBUF
: Set kernel transmit buffer size
TheZMQ_SNDBUF
option shall set the underlying kernel transmit buffer size for the socket to the specified size in bytes. A ( default ) value of -1 means leave the OS default unchanged.
where man 7 socket
says: ( credits go to @Matthew Slatery )
[...]
SO_SNDBUF
Sets or gets the maximum socket send buffer in bytes. The ker-
nel doubles this value (to allow space for bookkeeping overhead)
when it is set using setsockopt(), and this doubled value is
returned by getsockopt(). The default value is set by the
wmem_default sysctl and the maximum allowed value is set by the
wmem_max sysctl. The minimum (doubled) value for this option is
2048.
[...]
NOTES
Linux assumes that half of the send/receive buffer is used for internal
kernel structures; thus the sysctls are twice what can be observed on
the wire.
[...]
而
<小时/>
ZMQ_SNDHWM
: Set high water mark for outbound messages
TheZMQ_SNDHWM
option shall set the high water mark for outbound messages on the specified socket. The high water mark is a hard limit on the maximum number of outstanding messages ØMQ shall queue in memory for any single peer that the specified socket is communicating with. A ( non-default ) value of zero means no limit.
If this limit has been reached the socket shall enter an exceptional state and depending on the socket type, ØMQ shall take appropriate action such as blocking or dropping sent messages. Refer to the individual socket descriptions in zmq_socket(3) for details on the exact action taken for each socket type.
ØMQ does not guarantee that the socket will accept as many asZMQ_SNDHWM
messages, and the actual limit may be as much as 60-70% lower depending on the flow of messages on the socket.
语言讲解员,示例 trahunt:
拥有基础架构设置,其中 zmq.PUB
方将所有设置保留为默认值,这样的发件人将有大约 20、200、2000 zmq.SUB
如果不监听发送者,默认的、未修改的 O/S 内核缓冲区空间很快就会耗尽,就像每个 .bind()/.connect()
一样。 关系(每个 abonent )将尝试“填充”大约 ~ 1000 * aVarMessageSIZE [Bytes]
的总累积和。 的数据,曾经在 .send( ..., ZMQ_DONTWAIT )
中广播过方式&如果操作系统无法提供足够的缓冲空间——我们就这样——
"Houston, we have a problem..."
If the message cannot be queued on the socket, thezmq_send()
function shall fail witherrno
set toEAGAIN
.
Q.E.D.
关于ZeroMQ 缓冲区大小与高水位线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43791198/