fix(pipeline): stop idle keepalive polls, reduce idle requests#1322
Merged
therealaleph merged 2 commits intoMay 20, 2026
Merged
Conversation
c605acb to
d943fef
Compare
d943fef to
e870fb0
Compare
Previous cap of 2s caused ~1200 requests/5min idle with 15 deployments. New escalation: 20ms→80ms→200ms→500ms→2s→5s→10s→20s. After 15+ consecutive empties, sessions poll every 20s. Estimated idle reduction: ~1200/5min → ~200/5min. Zero latency impact on active traffic — select! races timer against client reads, so real data fires immediately. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e870fb0 to
259be25
Compare
therealaleph
approved these changes
May 20, 2026
Owner
therealaleph
left a comment
There was a problem hiding this comment.
Verified locally after adding the mixed-deployment guard: all-legacy idle sessions can stop polling, but mixed fleets keep emitting empty polls so round-robin can still reach a long-poll-capable peer.
Tests:
cargo test --lib tunnel_client::tests::tunnel_loop_keeps_polling_when_only_some_deployments_legacy -- --nocapturecargo test --libcargo build --release
Answered via LLM, Supervised @therealaleph
therealaleph
added a commit
that referenced
this pull request
May 20, 2026
Ship PR #1322 by @yyoyoian-pixel: Full Tunnel idle sessions now reduce empty keepalive request load, while mixed deployments keep polling so long-poll-capable peers can continue delivering remote-to-client data. Local verification: - cargo test --lib - cargo build --release - cargo build --bin mhrv-rs-ui --release --features ui
This was referenced May 20, 2026
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.
Summary
Stops keepalive polling on truly idle sessions and adds gradual backoff with separate idle tier tracking. Reduces idle Apps Script requests from ~1200/5min to ~35/5min for truly idle sessions.
How it works
Separate counters
consecutive_empty: controls pipeline depth management (resets to 0 on data — sessions can ramp up immediately)idle_tier: controls keepalive delay (halves on server-pushed data instead of full reset — prevents push notifications from yo-yoing the backoff)Measured results
Note: sessions receiving periodic server pushes (Instagram MQTT, Telegram, etc.) never reach idle_tier > 3 because they keep getting data. Those requests are real traffic, not wasted keepalive polls. True idle sessions (no server pushes) drop to zero polls.
No latency impact
tokio::select!races delay timer against client socket readsconsecutive_empty(resets to 0) — not affected by idle_tierTest plan
🤖 Generated with Claude Code