Skip to content

Add health-aware, retrying, stable round-robin load balancing - #4

Merged
dbpecka merged 1 commit into
mainfrom
claude/load-balancing-research-hFxRW
May 15, 2026
Merged

dbpecka merged 1 commit into
mainfrom
claude/load-balancing-research-hFxRW

Conversation

@dbpecka

@dbpecka dbpecka commented May 15, 2026

Copy link
Copy Markdown
Owner

The subscribe-side proxy previously round-robined across every node in the service index with no health awareness and no failover: dead nodes stayed in rotation, a failed pick dropped the client, and the node list was rebuilt from an unordered HashMap each connection so the counter didn't map to a stable node.

  • Track a local-only last_seen liveness marker on NodeInfo, refreshed on direct contact (outbound gossip sync, reverse-connection registration) and seeded on discovery. It is never gossiped or persisted.
  • find_service_nodes now sorts nodes by id for stable round-robin ordering and drops nodes whose marker is stale, failing open to the full set if every node would otherwise be excluded.
  • handle_connection returns a ConnectOutcome distinguishing failures before the client stream is touched (safe to retry) from a consumed client. run_proxy retries the next node on the former, bounded by MAX_TUNNEL_ATTEMPTS.

https://claude.ai/code/session_01BSwoCES9ZqbGdwCu594Dyj

The subscribe-side proxy previously round-robined across every node in
the service index with no health awareness and no failover: dead nodes
stayed in rotation, a failed pick dropped the client, and the node list
was rebuilt from an unordered HashMap each connection so the counter
didn't map to a stable node.

- Track a local-only `last_seen` liveness marker on `NodeInfo`, refreshed
  on direct contact (outbound gossip sync, reverse-connection
  registration) and seeded on discovery. It is never gossiped or
  persisted.
- `find_service_nodes` now sorts nodes by id for stable round-robin
  ordering and drops nodes whose marker is stale, failing open to the
  full set if every node would otherwise be excluded.
- `handle_connection` returns a `ConnectOutcome` distinguishing failures
  before the client stream is touched (safe to retry) from a consumed
  client. `run_proxy` retries the next node on the former, bounded by
  MAX_TUNNEL_ATTEMPTS.

https://claude.ai/code/session_01BSwoCES9ZqbGdwCu594Dyj
@dbpecka
dbpecka merged commit e50ac10 into main May 15, 2026
1 check passed
@dbpecka
dbpecka deleted the claude/load-balancing-research-hFxRW branch May 15, 2026 01:27
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.

2 participants