Skip to content

resource-manager: clarify connLimiter behavior and add WithDisableConnLimits option#3453

Open
alienx5499 wants to merge 2 commits intolibp2p:masterfrom
alienx5499:fix/rcmgr-connlimiter-docs-3431
Open

resource-manager: clarify connLimiter behavior and add WithDisableConnLimits option#3453
alienx5499 wants to merge 2 commits intolibp2p:masterfrom
alienx5499:fix/rcmgr-connlimiter-docs-3431

Conversation

@alienx5499
Copy link
Copy Markdown

Description

This PR addresses issue #3431 by clarifying the behavior of InfiniteLimits and the connection limiter (connLimiter) in the resource manager documentation.

Problem

When using InfiniteLimits to disable resource manager limits, users expected all limits to be disabled. However, the connLimiter operates independently and still enforces default limits:

  • IPv4: 8 concurrent connections per IP address (/32)
  • IPv6: 8 concurrent connections per /56 subnet, 64 per /48 subnet

This was not documented, leading to confusion when connections were still being limited despite using InfiniteLimits.

Changes

1. Documentation Updates (README.md)

  • Updated "How to disable limits" section to clarify that InfiniteLimits doesn't disable connLimiter
  • Added new "Connection Limiter" section with:
    • Explanation of default limits
    • Examples of how to customize limits using WithLimitPerSubnet
    • Examples of how to set network-specific limits using WithNetworkPrefixLimit
    • Documentation of the new WithDisableConnLimits() option

2. New Functionality (conn_limiter.go)

  • Added WithDisableConnLimits() option for easily disabling connection limits
  • This provides a convenient way to truly disable all limits when needed for testing/debugging

3. Tests (conn_limiter_test.go)

  • Added TestWithDisableConnLimits to verify the new option works correctly
  • Tests both IPv4 and IPv6 with 100+ concurrent connections from the same address

Usage Examples

Disabling all limits including connLimiter:

rm, err := rcmgr.NewResourceManager(
    rcmgr.NewFixedLimiter(rcmgr.InfiniteLimits),
    rcmgr.WithDisableConnLimits(),
)

Customizing per-subnet limits:

rm, err := rcmgr.NewResourceManager(
    limiter,
    rcmgr.WithLimitPerSubnet(
        []rcmgr.ConnLimitPerSubnet{{PrefixLength: 32, ConnCount: 16}}, // IPv4
        []rcmgr.ConnLimitPerSubnet{{PrefixLength: 56, ConnCount: 16}}, // IPv6
    ),
)

Setting network-specific limits:

rm, err := rcmgr.NewResourceManager(
    limiter,
    rcmgr.WithNetworkPrefixLimit(
        []rcmgr.NetworkPrefixLimit{
            {Network: netip.MustParsePrefix("192.168.1.0/24"), ConnCount: 100},
        },
        nil,
    ),
)

Testing

All tests pass:

  • Existing tests continue to work
  • New test TestWithDisableConnLimits verifies the new functionality
  • No linting errors

Related Issue

Fixes #3431

Checklist

  • Documentation updated
  • New functionality added with tests
  • All tests passing
  • No linting errors
  • Backwards compatible (no breaking changes)

@alienx5499 alienx5499 closed this Jan 15, 2026
@alienx5499 alienx5499 deleted the fix/rcmgr-connlimiter-docs-3431 branch January 15, 2026 08:06
@alienx5499 alienx5499 restored the fix/rcmgr-connlimiter-docs-3431 branch January 15, 2026 08:06
@alienx5499 alienx5499 reopened this Jan 15, 2026
@MarcoPolo
Copy link
Copy Markdown
Collaborator

Related to #3438

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

resource-manager: "conn" limits are not applied to connLimiter

2 participants