Skip to content

Default polling workers to CPU-based connection count (Option B: CPU-scaled)#1249

Open
LukeButters wants to merge 1 commit into
mainfrom
luke/option-b-cpu-polling-connections
Open

Default polling workers to CPU-based connection count (Option B: CPU-scaled)#1249
LukeButters wants to merge 1 commit into
mainfrom
luke/option-b-cpu-polling-connections

Conversation

@LukeButters

Copy link
Copy Markdown
Contributor

Summary

  • Polling Tentacle workers previously defaulted to 1 TCP connection, serialising all RPC calls. Under load (e.g. DRB), RPCs queue in Halibut's Pending Request Queue and time out — causing deployment failures.
  • This PR implements Option B from the RFC: the default connection count scales with CPU cores, clamped to [2, 8].
    • 1-core machine → 2 connections (minimum)
    • 4-core machine → 4 connections
    • 16-core machine → 8 connections (maximum)
  • The TentaclePollingConnectionCount env var still overrides the default; Halibut's MaximumActiveTcpConnectionsPerPollingSubscription cap remains in place as a server-side safeguard.
  • See also: Option A PR (fixed default of 5) for the simpler alternative.

Test plan

  • Verify existing tests pass
  • On a 4-core worker: confirm logs show "Starting 4 polling connections"
  • On a 1-core worker: confirm logs show "Starting 2 polling connections" (minimum enforced)
  • Verify TentaclePollingConnectionCount=1 env var still overrides to 1 connection
  • Verify TentaclePollingConnectionCount=10 is clamped to 8

🤖 Generated with Claude Code

Polling Tentacle workers previously defaulted to 1 TCP connection,
serialising all RPC calls. Under load (e.g. DRB), RPCs queue in Halibut's
Pending Request Queue and time out — causing deployment failures.

This PR implements Option B from the RFC: the default connection count
scales with available CPU cores (clamped to [2, 8]). A 4-core machine
gets 4 connections; a 1-core machine gets 2 (minimum); machines with
many cores are capped at 8. The TentaclePollingConnectionCount env var
still overrides this default.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@LukeButters LukeButters requested a review from a team as a code owner June 16, 2026 06:41
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.

1 participant