1

I need to build a sort of Instant Messaging system. From my brief exploration ZeroMQ and nanomsg are aimed at server-server communication in a backend distributed system, rather than managing +100K simultaneous end user client connections. Is that accurate? If so, is there a good message passing library in C that scales well with number of clients? Messages would be a mixture of server->client push and client->server request/response.

sg7
  • 6,108
  • 2
  • 32
  • 40
user1055568
  • 1,349
  • 13
  • 21
  • What makes you believe zmq/nanomsg aren't appropriate for this use? – Jason Jul 06 '15 at 18:31
  • @jason, see my comment below. The nanomsg author seems to dismiss the issue of overhead per tcp connection, which is one of the main issues in my case. Also, from my reading, it seems like nanomsg requires each socket to occupy a distinct role, which doesn't fit what I described above where both end points may initiate a message. – user1055568 Jul 06 '15 at 18:54
  • Hi! Which message library have you chosen at the end for your project? ZeroMQ, nanomsg or something else? – sg7 Dec 03 '17 at 12:38
  • @sg7, I ended up writing my own – user1055568 Dec 04 '17 at 16:17
  • Wow, impressive! How many connection can you handle? Is it based on any library? Thanks! – sg7 Dec 04 '17 at 16:21
  • Not sure. I followed design concepts here http://highscalability.com/blog/2013/5/13/the-secret-to-10-million-concurrent-connections-the-kernel-i.html. Built on BSD socket interface, with security via AES in EAX mode. Obsession with memory locality and "no connection without authentication first" made for messy API – user1055568 Dec 04 '17 at 16:50

2 Answers2

1

The nanomsg library is not a server to server oriented protocol. It has a few distinctive communication pasterns which cover wide range of communication needs. See: nanomsg communication patterns.

nanomsg library is extremely easy to use - nn_bind and nn_connect may be called multiple times on the same socket thus allowing the socket to communicate with multiple heterogeneous endpoints.

My preference for nanomsg over ZeroMQ is based on article1, article2 and my own coding experience. Take also a look at very good comparison given here: Are there any Python 2.7 alternatives to ZeroMQ that are released under the BSD or MIT license?

Indeed, nanomsg library makes the networking layer fast, scalable, and easy to use.

sg7
  • 6,108
  • 2
  • 32
  • 40
0

You will have a problem when you want to use a tcp/ip library to allow 100k simultaneous end user clients, staying alive, as you system will run out of ports to connect all those clients. It seems that both ZeroMQ and nanomsg address this problem. On the first glimpse I would say nanomsg is the better approach. But I would need to try that first.

Nanomsg seems actually designed to address exactly your problem.

ikrabbe
  • 1,909
  • 12
  • 25
  • 1
    There is no reason a server needs more than a single port to service 100K connections. The connections are distinguished by the remote (addr,port). It will need 100K sockets, but they can all use same local port. – user1055568 Jul 06 '15 at 18:09
  • The reason I decided nanomsg may not be well suited for this was the comment at https://github.com/nanomsg/nanomsg/blob/master/rfc/sp-tcp-mapping-01.txt on why it does not support multiplexing. Not that mutliplexing is a big issue for me, but the comment suggests there is no concern for the overhead of tcp connections in the design. – user1055568 Jul 06 '15 at 18:13
  • I agree, nanomsg would be good choice if you decided you needed 50 servers to manage all those client connections. Then it would help manage the communication among those 50 servers. But, I want to max out the number of clients per server, so I have less server-server comms. – user1055568 Jul 06 '15 at 18:18