Increase ZMQ socket limit

ZMQ's default is 1024, which we are close to hitting; this changes the
default for LokiMQ to 10000.
This commit is contained in:
Jason Rhinelander 2020-04-17 16:13:04 -03:00
parent 34bbaaf612
commit 2966427cc0
2 changed files with 11 additions and 0 deletions

View File

@ -237,6 +237,12 @@ void LokiMQ::start() {
LMQ_LOG(info, "Initializing LokiMQ ", bind.empty() ? "remote-only" : "listener", " with pubkey ", to_hex(pubkey));
int zmq_socket_limit = context.getctxopt(ZMQ_SOCKET_LIMIT);
if (MAX_SOCKETS > 1 && MAX_SOCKETS <= zmq_socket_limit)
context.setctxopt(ZMQ_MAX_SOCKETS, MAX_SOCKETS);
else
LMQ_LOG(error, "Not applying LokiMQ::MAX_SOCKETS setting: ", MAX_SOCKETS, " must be in [1, ", zmq_socket_limit, "]");
// We bind `command` here so that the `get_control_socket()` below is always connecting to a
// bound socket, but we do nothing else here: the proxy thread is responsible for everything
// except binding it.

View File

@ -196,6 +196,11 @@ public:
* disconnected. -1 means no limit. */
int64_t MAX_MSG_SIZE = 1 * 1024 * 1024;
/** Maximum open sockets, passed to the ZMQ context during start(). The default here is 10k,
* designed to be enough to be more than enough to allow a full-mesh SN layer connection if
* necessary for the forseeable future. */
int MAX_SOCKETS = 10000;
/** Minimum reconnect interval: when a connection fails or dies, wait this long before
* attempting to reconnect. (ZMQ may randomize the value somewhat to avoid reconnection
* storms). See RECONNECT_INTERVAL_MAX as well. The LokiMQ default is 250ms.