WebSocket vs Polling for Solana Account Updates in Trading Bots
Compares accountSubscribe WebSocket subscriptions against periodic getAccountInfo polling for detecting on-chain state changes relevant to trading signals. Explains when each approach breaks down and how to combine both for resilient coverage.
Every millisecond you spend waiting for an on-chain state change is a millisecond your entry price is drifting. Choosing the wrong update mechanism for Solana account data is one of the most common infrastructure mistakes in bot development — and it usually only surfaces under load or in volatile conditions. Here is what the two approaches actually look like in production, where each one breaks, and how to wire them together so neither failure mode takes you down.
How accountSubscribe Actually Works
The accountSubscribe WebSocket method opens a subscription on an RPC node, which then pushes a notification to your client whenever the target account's data or lamport balance changes. Solana's gossip network means your RPC node learns about a confirmed slot roughly 400–600 ms after the validator cluster processes it, depending on leader distance and network conditions. The critical detail is that the push is event-driven at the node level — you are not receiving raw gossip; you are receiving a filtered diff that the RPC node computes and forwards.
This matters because your subscription is only as current as the node you are connected to. A lagging node — one that is 5–10 slots behind — will deliver stale notifications timed to its own view of the chain, not the actual cluster tip. Under heavy load, many public RPC providers throttle subscription counts or silently drop notifications rather than queue them. If your bot is subscribed to 50+ accounts across a busy pool, you will see gaps.
How Polling with getAccountInfo Works
Polling calls getAccountInfo (or getMultipleAccounts) on a cadence you control. The upside is determinism: every N milliseconds you get a snapshot you explicitly requested, and you can target a specific commitment level — processed, confirmed, or finalized. The downside is purely latency math. At 200 ms polling intervals you will detect a state change anywhere between 0 and 200 ms after it lands, giving you a worst-case median lag of ~100 ms on top of whatever RPC round-trip you are paying.
More practically, polling burns RPC credits at a known rate. Polling 20 accounts every 100 ms is 200 calls/second sustained. Most paid RPC tiers price this into their plans, but it adds up fast when you are watching a deep liquidity pool with dozens of relevant accounts — exactly the kind of setup you see in production Solana bots.
Where WebSockets Break in Production
Three failure modes will hit you before you think they will:
- Silent disconnects. WebSocket connections drop without triggering an error event on several popular RPC providers. Your bot believes it is subscribed; it is not. You need a liveness probe — a synthetic heartbeat account you control, written to every 30 seconds, whose subscription you monitor to confirm the socket is alive.
- Subscription acknowledgment without delivery. The server confirms your subscription ID, but state-change notifications never arrive because the node is overloaded. You cannot distinguish this from a quiet account unless you independently verify.
- Reorganizations. A
processed-commitment subscription can deliver a notification for a slot that is later rolled back. If your signal logic is tight on timing, you can act on state that never finalizes.
The standard fix is to treat every subscription as untrustworthy until corroborated. When a notification fires, issue a synchronous getAccountInfo at confirmed commitment before acting. Yes, this adds one RPC round-trip. The latency cost is typically 15–40 ms on a co-located node, which is almost always worth the safety margin.
Where Polling Breaks in Production
Polling's failure mode is straightforward: you miss events that open and close between polling intervals. A limit order that fills and closes a position account within one polling window is invisible to you. On Solana, where a full transaction lifecycle can complete in 400 ms, a 500 ms polling interval has a realistic chance of missing short-lived state changes entirely.
The other issue is backpressure. If your polling loop awaits each call sequentially, and RPC latency spikes from 30 ms to 300 ms during a busy epoch, your effective polling rate degrades 10x without any alarm firing. Concurrent polling with bounded parallelism and explicit timeout handling is non-negotiable.
Combining Both for Resilient Coverage
The architecture we use in practice: WebSocket subscriptions for low-latency notification, polling as a background reconciliation layer. Subscriptions fire the signal path immediately. A parallel polling loop runs every 1–2 seconds and compares its snapshot to the last known state from subscriptions. Any discrepancy triggers a re-subscribe and a forced snapshot read. This catches silent disconnects, missed notifications, and any drift between your in-memory view and actual chain state.
Commitment selection matters here too. Run subscriptions at processed for speed; run your reconciliation poll at confirmed. If the two diverge by more than one confirmed slot, treat your processed state as suspect and wait for confirmation before acting.
For accounts that carry outsized risk — collateral accounts, margin position accounts, vault accounts — add an additional finalized-commitment poll on a slower cadence (5–10 seconds) as a hard backstop. Finalized state is the ground truth; everything else is a prediction.
Monitoring and Alerting
Instrument both paths separately. Track notification-to-processing latency for every subscription, and track polling round-trip times per endpoint. Alert on subscription silence windows longer than twice your expected heartbeat interval. If your monitoring shows subscriptions going quiet for 60+ seconds during volatile market hours, you almost certainly have a silent disconnect problem, not a quiet market.
Node selection has an outsized impact here. A dedicated node or a high-tier provider with guaranteed subscription delivery SLAs will outperform shared public endpoints by a wide margin under load. The cost delta is trivial relative to a single missed liquidation event.
If you want infrastructure like this running under your strategy rather than something you have to build yourself, reach out to TierZero — we design and operate these systems end-to-end.
Need a bot like this built?
We design, build and run trading bots on Solana, Hyperliquid and Polymarket.
Start a projectMore from the blog
Public vs Paid RPC: How to Run a Fair Benchmark
A fair comparison of public and paid RPC endpoints must account for quotas, workload, freshness and support guarantees.
Read articleRPC Benchmark Percentiles Explained: p50, p95 and p99
Why averages hide the latency spikes that break trading bots, wallets and production blockchain applications.
Read articleHyperliquid REST vs WebSocket Benchmark: What to Measure
A benchmark plan for Hyperliquid market data that separates request latency from streaming freshness and recovery.
Read article