Giter Club home page Giter Club logo

Comments (5)

gdamore avatar gdamore commented on July 24, 2024

If you open a lot of connections, it is indeed possible to blow past the limit. If you want this level of scalability, then yes, you need to do so with ulimit. And that is the correct way to do this on UNIX/Linux systems.

However, it's quite likely that if you're not using legacy notification mechanisms (i.e. you use AIO for example), then NNG may wind up using quite a few less open files than ZMQ. ZMQ needs to open a two additional files for each socket (not connection), to provide for notification of events. NNG has to do this if you use the polling file descriptor method (which might needed e.g. with some language plugins), but if you use the more efficient AIO mechanism then it doesn't do this.

No matter how you cut it, you will have (in both ZMQ and NNG) one open file descriptor per active TCP connection. That's unavoidable, as it's how these connections work on POSIX (and even Windows) systems.

from nng.

gdamore avatar gdamore commented on July 24, 2024

Closing as this is just a question, which I've answered.

from nng.

cathaysia avatar cathaysia commented on July 24, 2024

Thanks for your answer. In my program (14 NIC interfaces, 2 pub-sub sockets, 16 threads), zmq opens 200+ file descriptors whenever there is a sub socket connected. nng will this happen?

from nng.

gdamore avatar gdamore commented on July 24, 2024

That sounds super excessive.

The issue isn't the number of NIC interfaces, but how many instances of your client you run. Each time a new client connection is established, that will be an FD (actually 2, one for the client and one for the server).

I suspect that if you're seeing this behavior even with ZMQ that there is a logic bug in your code somewhere. NNG will definitely not do that, unless you are constantly redialing. (And you shouldn't do that) -- call NNG dial just once (per client), and then keep using the same socket for all your needs. :-)

from nng.

cathaysia avatar cathaysia commented on July 24, 2024

Yes, I don't know exactly how zeromq works. but

  1. Change the listening port from "tcp://0.0.0.0:xxx" to "tcp://127.0.0.1:xxx"
  2. Reduce the number of threads in zmq context
    This improved my program significantly.
    I don't intend to talk too much about zmq under nng. Also please understand.

Thank you very much for your answer :)

from nng.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.