Problems with max-sockets in 2.1.0

Description

A number of issues with max-sockets in 2.1.0:

  • The limit seems 1 off, i.e. if I set it to 1000, I can create exactly 999 sockets.

  • Opening 509 sockets provokes an abort in mailbox.cpp:374 on an untuned Linux (508 works).

  • Is the limit of 512 sockets reasonable, given that in 2.0.x it was effectively unlimited? This may break many applications. I'd suggest a rather higher limit (10K?) and explanation in the docs on how to tune for per-process file handle limits.

Sample program to test max-sockets:

// Exhaust file handles per process

#include "zmq.h"
#include "stdio.h"

int main ()
{
void *context = zmq_init (1);

int socket_nbr;
for (socket_nbr = 0; socket_nbr < 8000000; socket_nbr++) {
void *socket = zmq_socket (context, ZMQ_REQ);
if (!socket)
break;
}
printf ("This system allows up to %d sockets\n", socket_nbr);
return 0;
}

Environment

None

Activity

Show:
Martin Sustrik
November 11, 2010, 12:25 PM

Pieter, yes the limit can be increased. The overhead is 4/8 bytes of memory per socket so it's basically negligible. You are right that 512 limit can be exceeded on massively multicore systems, with many threads interacting via inproc.

Chuck, that's SNDBUF/RCVBUF, right? That's relevant to the different problem, the one with socketpair getting full that Mato is dealing with currently.

chuckremes
November 11, 2010, 2:47 PM

sustrik, yes, I was referring to getsockopt(SO_SNDBUF) returning weird values as used by the code in zmq::mailbox_t::send.

Martin Sustrik
February 8, 2011, 3:21 PM

The max_sockets setting is now honoured rigorously.

Fix 889424e.

Martin Sustrik
March 1, 2011, 3:30 PM

Can you test and close this issue if fixed?

PieterP
March 1, 2011, 9:17 PM

Confirmed fix (requires increase in file handles per process before it will run). See http://www.zeromq.org/docs:tuning-zeromq.

Assignee

Unassigned

Reporter

PieterP

Labels

None

Priority

Configure