Skip to main content

WebSocket Scaling

WebSocket RPC turns each client into a long-lived resource consumer. Capacity planning must account for open connections, subscriptions per connection, message fanout, heartbeat traffic, and reconnect storms.

ConcernGateway policyClient policy
Load balancingUse sticky sessions when upstream subscription state is in-memoryReconnect and resubscribe after disconnect
Connection countPer-key and per-IP concurrent connection limitsShare connections inside one app process
Subscription countMethod-specific caps for logs, blocks, objects, or accountsSubscribe narrowly and unsubscribe when unused
HeartbeatsIdle timeout plus ping/pong or app-level heartbeatDetect dead connections before sending critical work
Reconnect stormsJittered retry and admission limitsExponential backoff with jitter

Ethereum clients commonly use WebSocket for eth_subscribe over port 8546 (Geth RPC). Solana exposes WebSocket methods such as logsSubscribe and account subscriptions (Solana WebSocket). Sui exposes subscription-oriented services, including the gRPC SubscriptionService in its fullnode protocol surface (Sui Full Node gRPC methods).

const reconnectDelayMs = Math.min(30_000, 500 * 2 ** attempt) * (0.5 + Math.random());

:::warning Streaming is not indexing by itself Subscriptions can drop, reconnect, or miss messages during failover. Persist cursors and reconcile with polling or checkpoint reads for durable indexers. :::

For durable pipelines, combine WebSocket or gRPC streams with /developer/indexer-architecture.