Repository navigation
Limit inbound events and absorb shared broadcast bursts - #537
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Incoming events can drive shared-tag broadcasts fast enough to disconnect other users, especially pages with only one element. Pace inbound events per Request and give small pages enough queue space to absorb synchronized bursts.
Jaws.MaxEventRate: 100 records/s by default, zero selects the default, negative disables it.Click,ContextMenu,Input, andJsVarshare the budget, including records batched in one frame. Events wait in order;Removeconsumes no budget. Usegithub.com/linkdata/rate.wire.ReadLoop. Check cancellation after an enabled limiter wait; preserve shutdown and idle-ping behavior.No per-IP aggregate budget is added. Per-Request pacing and burst headroom do not prevent overload when aggregate broadcasts exceed a recipient's sustained capacity; applications should use
Dirty/Updatecoalescing or keep broadcasts within their clients' bandwidth.Validation: focused transport/request tests, full
go test -race ./...and production tests withJAWS_REQUIRE_NODE=1,go generate,gofmt,go vet,staticcheck,golangci-lint,gosec, andgo buildpass. Reviewed the affected rendered Go docs separately. Tests cover batching, ordering, defaults, disabled/custom rates, idle recovery, cancellation, ping timing, and a continuously reading victim under real WebSocket traffic.The committed
BenchmarkWSBroadcastBurstuses 16 synchronized senders, real WebSockets, and an unthrottled one-element recipient. Server-side pacing is disabled to isolate queue capacity. Linux/arm64; six samples per rate/CPU combination:Total recipient disconnects fell from 12/24 to 0/24. Benchstat reports the 400/s, 4-CPU delivery improvement at p=0.002. An exploratory 16/32/64-capacity sweep also passed at 32; 64 provides additional burst headroom. These short runs measure burst tolerance, not a guarantee against sustained overload. Time/op includes client pacing; allocations include more completed delivery work when the recipient stays connected.
Fixes #536.