[zeromq-dev] Handling high socket or connection counts

Olaf Mandel o.mandel at menlosystems.com
Thu Feb 6 17:12:40 CET 2014

Am 06.02.2014 16:09, schrieb Goswin von Brederlow:
> On Thu, Feb 06, 2014 at 01:38:48PM +0100, Olaf Mandel wrote:
>> I get this error either when I run into the ZMQ_MAX_SOCKETS limit or
>> into the operation system resource limit (ulimit -n) on Linux. On
>> Windows, I can be lucky not to cause a Bluescreen!
>> * one file descriptor per socket
>> * for tcp, one file descriptor per connection
> [...] When you use
> threads then you should be using inproc. That only uses a bit of
> memory (right?) and no file descriptors at all. Problem solved.

and thank you for the quick reply. It is true that I mixed up hitting
the ZMQ_MAX_SOCKETS limit and hitting the OS limit: I only use up file
descriptors for tcp, not for inproc. So on *nix using inproc is
definitely feasible.

But on Windows (which I have to support as well), this will not work: I
have a segmentation fault when connecting the 1021st client socket. Is
this a known equivalent of *nix "ulimit -n"?

> But what if you don't use threads? Then inproc won't work. But also
> you don't have a limit of 1024 sockets. Only 1024 file descriptors per
> executable. By forking or starting seperate executables you can have
> many more sockets, colletively. How much more? There are only 65536
> ports and 0-1023 is reserved for root. So you won't get verry far with
> tcp. If you need more then you need to use multiple hosts or at least
> containers with different IPs.
A good point: I thought I was save because I only bind to very few port
numbers and mostly connect. But even a socket that connects to a
different port on localhost still consumes a second port number, doesn't
it? I didn't consider this.

So from the point of view of my original question: one approach is to
use inproc where possible, reducing the reliance on tcp sockets?

Best regards,
Olaf Mandel
Olaf Mandel
phone: +49-89-189166-250
fax:   +49-89-189166-111
Menlo Systems GmbH
Am Klopferspitz 19a, D-82152 Martinsried
Amtsgericht München HRB 138145
Geschäftsführung: Dr Michael Mei, Dr Ronald Holzwarth
USt-IdNr. DE217772017, St.-Nr. 14316170324

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140206/e899df57/attachment.sig>

More information about the zeromq-dev mailing list