Giter Club home page Giter Club logo

Comments (12)

burdiyan avatar burdiyan commented on June 1, 2024

Facing the same issue.

from go-libp2p.

sukunrt avatar sukunrt commented on June 1, 2024

This means that you have configured the connection manager in such a way that it will never be used.

Libp2p uses two modules for connection managements. Resource manager limit(rcmgr) is a hard limit. If the rcmgr limit is set to 1 you will only have 1 open connection.

The ConnMgr limit is a soft limit of sort. It allows for a burst of connections between ConnMgr.LowWaterMark and ConnMgr.HighWaterMark. This allows for a burst of connections between Low and high watermark. But when you exceed the high watermark, the system trims connections down to low watermark.

In your case HighWatermark trimming never happens because it's higher than the rcmgr limit. Ideally your high watermark limit should be a bit less than the rcmgr connections limit.

from go-libp2p.

juligasa avatar juligasa commented on June 1, 2024

I have the same issue, even if I set unlimited resources, it still complains about the system limit being 1 WARN p2p-config config/config.go:304 rcmgr limit conflicts with connmgr limit: conn manager high watermark limit: 768, exceeds the system connection limit of: 1
My configuration so far:

cm := mustConnMgr(connmgr.NewConnManager(
	512,
	768,
	connmgr.WithGracePeriod(r.cfg.ConnMgr.ConnMgrGrace),
))

opts = append(opts,
	libp2p.ConnectionManager(cm),
)

scalingLimits := rcmgr.DefaultLimits

// Add limits around included libp2p protocols
libp2p.SetDefaultServiceLimits(&scalingLimits)
// Turn the scaling limits into a concrete set of limits using `.AutoScale`. This
// scales the limits proportional to your system memory.
scaledDefaultLimits := scalingLimits.AutoScale()

// Tweak certain settings
cmcfg := rcmgr.PartialLimitConfig{
	System: rcmgr.ResourceLimits{
		Streams:  rcmgr.Unlimited,
		Conns:    rcmgr.Unlimited,
		FD:      rcmgr.Unlimited,
		Memory:  rcmgr.Unlimited64,
	},
	// Everything else is default. The exact values will come from `scaledDefaultLimits` above.
}

// Create our limits by using our cfg and replacing the default values with values from `scaledDefaultLimits`
limits := cmcfg.Build(scaledDefaultLimits)

// The resource manager expects a limiter, so we create one from our limits.
limiter := rcmgr.NewFixedLimiter(limits)

// Metrics are enabled by default. If you want to disable metrics, use the
// WithMetricsDisabled option
// Initialize the resource manager
rm, err := rcmgr.NewResourceManager(limiter)
if err != nil {
	panic(err)
}
	
opts = append(opts,
	libp2p.ResourceManager(rm),
)

r.host, err = libp2p.New(opts...)
if err != nil {
	return err
}

from go-libp2p.

burdiyan avatar burdiyan commented on June 1, 2024

@juligasa I fixed that by using rcmgr.NewFixedLimiter(rcmgr.InfiniteLimits) instead of trying to manually expand the default limits to be unlimited. That fixed the issue with the connmgr conflict.

from go-libp2p.

juligasa avatar juligasa commented on June 1, 2024

Oh, I just followed the package recommendations at
https://github.com/libp2p/go-libp2p/tree/master/p2p/host/resource-manager#usage
I wonder why it did not work as expected.

from go-libp2p.

richard-ramos avatar richard-ramos commented on June 1, 2024

This means that you have configured the connection manager in such a way that it will never be used.

I'm confused on why I'm getting that warning even tho I have not configured any custom connection manager, but using the defaults provided by go-libp2p as seen on the example code i wrote here: #2628 (comment) . Shouldnt go-libp2p by default configure the connection manager with settings that avoid this warning being emitted?

from go-libp2p.

sukunrt avatar sukunrt commented on June 1, 2024

@juligasa you need to set the Conn scope limit too.

	// Tweak certain settings
	cmcfg := rcmgr.PartialLimitConfig{
		System: rcmgr.ResourceLimits{
			Streams: rcmgr.Unlimited,
			Conns:   rcmgr.Unlimited,
			FD:      rcmgr.Unlimited,
			Memory:  rcmgr.Unlimited64,
		},
		// Everything else is default. The exact values will come from `scaledDefaultLimits` above.
		Conn: rcmgr.ResourceLimits{
			Conns: rcmgr.Unlimited,
		},
	}

Shouldnt go-libp2p by default configure the connection manager with settings that avoid this warning being emitted?

I agree. I'll check how to improve the situation here.

from go-libp2p.

juligasa avatar juligasa commented on June 1, 2024

@juligasa you need to set the Conn scope limit too.

I see, I thought the System level was the top abstraction scope, though. And by setting it to unlimited would cause the rest of scopes to be also unlimited (if no further restriction was in place). According to the documentation:

The system scope is the top level scope that accounts for global resource usage at all levels of the system. This scope nests and constrains all other scopes and institutes global hard limits

I guess the libp2p.SetDefaultServiceLimits overrides the connection limit to 1 and hence, the warning.

from go-libp2p.

sukunrt avatar sukunrt commented on June 1, 2024

This constraint is the other way round, no?

The system scope is the top level scope that accounts for global resource usage at all levels of the system. This scope nests and constrains all other scopes and institutes global hard limits

If the system scope is 1 connection, peer scope cannot be 10 connections

On the other hand

If the system scope is 100 connections, peer scope can be 1 connection
If the system scope is inf connections, peer scope can be 1 connection

from go-libp2p.

juligasa avatar juligasa commented on June 1, 2024

Sure you're right. The problem is with default peer scopes though. I did not expect them to be so tight by default (actually, allowing only 1 connection is pretty tight). Will set limits accordingly, thanks!

from go-libp2p.

sukunrt avatar sukunrt commented on June 1, 2024

You're right, @juligasa . This warning doesn't make sense. The system connection limit is what we should check. I've raised a PR to fix this.

Just to be clear:

You DO NOT NEED to increase Conn Scope limit as I suggested here. I'm sorry about that. #2628 (comment)
The Connection scope only ever needs 1 connection because it is well tied to the connection 😓

from go-libp2p.

juligasa avatar juligasa commented on June 1, 2024

Ok, Makes sense

from go-libp2p.

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.