Code Monkey home page Code Monkey logo

Comments (5)

AMarti96 avatar AMarti96 commented on July 30, 2024

To provide more detail, I was able to extract the number of connections in our current NATS server(running inside a Kuberentes cluster and populating Streams/Consumers via NACK). Using nats-top I was able to get the following

image

as you can see, all of them (the 95 connections in this specific screenshot) are from jetstream-controller, which is NACK creating the Streams/Consumers and never disconnecting

from nack.

AMarti96 avatar AMarti96 commented on July 30, 2024

The problem seems to be only when the connection to NATS is defined in the account CRD. In the code, that means when crdConnect is set to true.

When setting one NATS connection in the overall server settings (crdConnect set to false) it doesn't matter how many objects I create or how many times the connection is retried, only 1 connection is reported:

image

With that in mind, I think the error may come in this part of the code:

natsServers := strings.Join(append(servers, accServers...), ",")
newNc, err := nats.Connect(natsServers, opts...)
if err != nil {
return fmt.Errorf("failed to connect to nats-servers(%s): %w", natsServers, err)
}
c.normalEvent(str, "Connecting", "Connecting to new nats-servers")
newJm, err := jsm.New(newNc)
if err != nil {
return err
}
newJsmc := &realJsmClient{nc: newNc, jm: newJm}
if err := op(c.ctx, newJsmc, spec); err != nil {
return err
}
newJsmc.Close()

from nack.

caleblloyd avatar caleblloyd commented on July 30, 2024

Thanks for reporting! We should be able to put a connection pooler into NACK to prevent this. There is already an implementation in the nats-surveyor repo.

We'll port it over should be able to get that done next week

from nack.

caleblloyd avatar caleblloyd commented on July 30, 2024

Connection pooling reference from nats-surveyor: https://github.com/nats-io/nats-surveyor/blob/main/surveyor/conn_pool.go

from nack.

caleblloyd avatar caleblloyd commented on July 30, 2024

Connection pool added in v0.14.0

from nack.

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.