【发布时间】:2017-10-03 02:58:38
【问题描述】:
【问题讨论】:
【问题讨论】:
ZMQ_SNDBUF:设置内核传输缓冲区大小ZMQ_SNDBUF选项应将套接字的底层内核传输缓冲区大小设置为以字节为单位的指定大小。 ( default ) 值为 -1 表示保持操作系统默认值不变。
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:为出站消息设置高水位标记ZMQ_SNDHWM选项应为指定套接字上的出站消息设置高水位标记。高水位线是对指定套接字正在与之通信的任何单个对等方的最大ØMQ 应在内存中排队的未完成消息数的硬性限制。 ( non-default ) 值为零表示没有限制。
如果已达到此限制,则套接字将进入异常状态,并且根据套接字类型,ØMQ 应采取适当的措施,例如阻止或丢弃已发送的消息。请参阅zmq_socket(3) 中的各个套接字描述,了解对每种套接字类型采取的具体操作的详细信息。
ØMQ 确实不保证套接字将接受尽可能多的ZMQ_SNDHWM消息,实际限制可能会降低 60-70%,具体取决于套接字上的消息流。
有一个基础设施设置,其中 zmq.PUB 方面将所有设置保留为默认值,这样的发件人将有大约 20、200、2000 zmq.SUB abonent 监听发送者,很快就会耗尽默认的、未修改的 O/S 内核缓冲区空间,因为每个 .bind()/.connect() 关系(每个 abonent )都会尝试“填充”尽可能多的~ 1000 * aVarMessageSIZE [Bytes] 数据的累计总和,一旦以.send( ..., ZMQ_DONTWAIT ) 方式广播并且如果 O/S 无法提供足够的缓冲区空间 - 就这样 - p>
“休斯顿,我们有问题...”
如果消息不能在套接字上排队,zmq_send()函数应该失败,errno设置为EAGAIN。
Q.E.D.
【讨论】: