Skip to content

fix: add global process-level rate limit bucket above per-connection checks (PILOT-317)#30

Merged
TeoSlayer merged 1 commit into
mainfrom
openclaw/pilot-317-20260531-001118
Jun 6, 2026
Merged

fix: add global process-level rate limit bucket above per-connection checks (PILOT-317)#30
TeoSlayer merged 1 commit into
mainfrom
openclaw/pilot-317-20260531-001118

Conversation

@matthew-pilot
Copy link
Copy Markdown
Collaborator

What failed

The rate limiter in accept.go is per-IP only. A botnet with 256 IPs at 100 req/s each can push 25.6k req/s — well above expected normal load. The existing per-connection rate check (500 req/s ceiling per connection) doesn't bound the aggregate.

Why this fix

Add a globalRateBucket (1000 req/s process-wide) checked in both handleJSONConn and handleBinaryConn after the 5-second grace period. If total request rate across all connections exceeds the global ceiling, the connection is closed with a warning log.

Verification

  • go build ./...
  • go vet ./...
  • go test ./... ✅ (18/18 packages)
  • 1 file, +44/−0

Closes PILOT-317

@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

📊 PR Status — #30 PILOT-317

Field Value
State OPEN
Mergeable ✅ MERGEABLE (CLEAN)
Draft No
Branch openclaw/pilot-317-20260531-001118main
Files 1 file, +44/−0 (accept/accept.go)
Labels (none)

CI Checks (2/2 passing)

Check Result
test ✅ pass
codecov/patch ✅ pass

Author

matthew-pilot (bot)

Created: 2026-05-31 00:11 UTC
Updated: 2026-05-31 00:15 UTC

@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

🔍 Canary & Ticket Status Update

Canary: 🟡 queued — Run #26698606660 (dispatched 00:11 UTC, awaiting runner)

Jira PILOT-317: QA/IN-REVIEWrendezvous: rate limiter is per-IP only — no global aggregate cap

  • Priority: Medium | Assignee: Teodor Calin
  • Last updated: 2026-05-31 03:11 EEST

@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

🔍 PR Explanation — #30 PILOT-317

What this does

Adds a process-wide global rate-limit bucket (1000 req/s) that sits above the existing per-connection rate checks in accept/accept.go.

The problem

The existing rate limiter is per-IP only. A distributed botnet with 256 IPs at 100 req/s each can push 25.6k req/s — well above expected normal load. The per-connection ceiling (500 req/s) doesn't bound the aggregate across all connections.

The fix

1. New globalRateBucket struct (lines 120–155)

  • Token-bucket algorithm with configurable rate
  • allow(now) returns false when tokens are exhausted
  • Tokens refill at the configured rate (1000/s)

2. newGlobalRateBucket(1000) constructor (line 544)

  • Initialized in NewAcceptor alongside the existing per-IP rate limiter

3. Global check in handleJSONConn (lines 836–842)

  • After the 5-second per-connection grace period, checks globalBucket.allow() before processing the request
  • If global cap is exceeded → closes connection with a warning log

4. Global check in handleBinaryConn (lines 924–930)

  • Same pattern for binary connections

Scope

  • 1 file changed (accept/accept.go), +44/−0
  • No new dependencies
  • No API or config changes
  • Backward compatible — normal traffic below 1k req/s is unaffected

@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

📊 PR Status Update — #30 PILOT-317

Field Value
State OPEN
Mergeable ✅ MERGEABLE
CI 2/2 pass (test ✅, codecov/patch ✅)
Canary 🟡 Running — Run #26698606660 (queued)
Jira IN WORK (claimed, decision posted)
Last updated 2026-05-31T00:37Z

…nection checks (PILOT-317)

The rate limiter in accept.go is per-IP only. A botnet with 256 IPs at
100 req/s each can push 25.6k req/s — well above expected normal load.
The existing per-connection rate check (500 req/s ceiling per connection)
doesn't bound the aggregate.

Add a globalRateBucket (1000 req/s process-wide) checked in both
handleJSONConn and handleBinaryConn after the 5-second grace period.
If total request rate across all connections exceeds the global ceiling,
the connection is closed with a warning log.

Closes PILOT-317
@TeoSlayer TeoSlayer force-pushed the openclaw/pilot-317-20260531-001118 branch from d81a36f to 21bee20 Compare June 6, 2026 08:32
@TeoSlayer TeoSlayer merged commit 593d49a into main Jun 6, 2026
3 checks passed
@TeoSlayer TeoSlayer deleted the openclaw/pilot-317-20260531-001118 branch June 6, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants