[management] Add gRPC update debouncing mechanism#5227
Conversation
Implements backpressure handling for peer network map updates to efficiently handle rapid changes. First update is sent immediately, subsequent rapid updates are coalesced, ensuring only the latest update is sent after a 1-second quiet period.
📝 WalkthroughWalkthroughA per-peer UpdateDebouncer was added and integrated into the gRPC server update loop. Updates are either sent immediately (first after a quiet period) or coalesced and flushed after a debounce interval; debouncer lifecycle and timer-driven flushes are managed per connection. Changes
Sequence DiagramssequenceDiagram
participant Peer
participant Server
participant Debouncer
participant Timer
Peer->>Server: Send Update (1st)
Server->>Debouncer: ProcessUpdate(msg)
Debouncer->>Debouncer: start timer
Debouncer-->>Server: return true (send immediately)
Server->>Peer: Send Update immediately
Peer->>Server: Send Update (2nd, rapid)
Server->>Debouncer: ProcessUpdate(msg)
Debouncer->>Debouncer: set pending, reset timer
Debouncer-->>Server: return false (defer)
Peer->>Server: Send Update (3rd, rapid)
Server->>Debouncer: ProcessUpdate(msg)
Debouncer->>Debouncer: replace pending, reset timer
Debouncer-->>Server: return false (defer)
Timer->>Debouncer: Timer fires (quiet period)
Debouncer-->>Server: TimerChannel signal
Server->>Debouncer: GetPendingUpdate()
Debouncer-->>Server: return pending update (last one)
Server->>Peer: Send pending update
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…g and timeout handling
|



Implements backpressure handling for peer network map updates to efficiently handle rapid changes. The first update is sent immediately; subsequent rapid updates are coalesced, ensuring that only the latest update is sent after a 1-second quiet period.
Intermediate changes do not need to be applied, so the focus is on processing only the final update in the queue.
This also fixes lost network updates on the producer side. The network map producer should not depend on network-related layers. Todo: set the channal size to 1 and set it to blocker.
Describe your changes
Issue ticket number and link
Stack
Checklist
Documentation
Select exactly one:
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
https://github.com/netbirdio/docs/pull/__
Summary by CodeRabbit
Infrastructure
Tests