Solana gRPC vs WebSocket vs RPC — Which to Use
Solana offers three main approaches for consuming on-chain data: RPC polling, WebSocket subscriptions, and gRPC (Yellowstone) streaming. Each has different latency, reliability, and complexity characteristics.
Disclosure: This site is affiliated with Supanode. Supanode links on this page are marked. All technical comparisons are based on public documentation and protocol specifications.
Comparison overview
| Feature | RPC polling | WebSocket | gRPC (Yellowstone) |
|---|---|---|---|
| Latency | Highest (~400ms+) | Medium (~200ms) | Lowest (~50ms) |
| Delivery model | Request/response | Push (subscribe) | Push (stream) |
| Missed events | Possible between polls | Possible on disconnect | Backfill possible |
| Filtering | Per-request params | Subscription filters | Server-side filters |
| Throughput | Limited by rate limits | Connection-limited | High throughput |
| Complexity | Lowest | Medium | Highest |
| Cost | Per-request | Included in plan | Usually separate pricing |
When to use each
RPC polling
Best for: simple queries, infrequent reads, prototyping.
// Poll account balance every 5 seconds
setInterval(async () => {
const balance = await connection.getBalance(pubkey);
console.log("Balance:", balance);
}, 5000);
Drawbacks: wastes requests on unchanged data, latency is poll interval + request time, misses events between polls.
WebSocket subscriptions
Best for: real-time account updates, transaction notifications, moderate-throughput applications.
connection.onAccountChange(pubkey, (accountInfo) => {
console.log("Account changed:", accountInfo.data);
});
connection.onLogs(programId, (logs) => {
console.log("Program log:", logs);
});
Drawbacks: connections drop under load, no guaranteed delivery, reconnection loses events, limited filtering server-side.
gRPC (Yellowstone)
Best for: high-throughput indexing, trading bots, real-time analytics, any workload that cannot afford missed updates.
// Yellowstone gRPC subscription
const stream = client.subscribe();
stream.write({
accounts: {
tokenAccounts: {
owner: ["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"],
filters: [{ datasize: 165 }],
},
},
});
Advantages: server-side filtering reduces bandwidth, supports backfill on reconnect, handles high-volume streams efficiently.
Decision flowchart
Need real-time data?
No → RPC polling
Yes → Can afford missed events?
Yes → WebSocket
No → Need high throughput (>100 updates/sec)?
No → WebSocket with reconnection logic
Yes → gRPC (Yellowstone)
FAQ
Is gRPC always better than WebSocket? Not always. gRPC adds infrastructure complexity and cost. For applications that monitor a few accounts and can tolerate occasional missed events, WebSocket is simpler and cheaper.
Can I use WebSocket and gRPC together? Yes. A common pattern uses gRPC for critical data streams (order monitoring, liquidation detection) and WebSocket for lower-priority notifications. RPC polling serves as a fallback for both.
What is Yellowstone? Yellowstone is the Geyser plugin framework that exposes Solana validator data via gRPC. It streams account updates, transactions, slots, and blocks directly from the validator without going through the RPC layer.
Updated: