⭐Solana gRPC Best Practices
Optimise your Solana gRPC setup for low-latency streaming by following these common best practices.
The Solana Yellowstone geyser gRPC stream is the most direct and efficient way to access real-time data from the Solana blockchain. To truly harness its power for high-frequency trading, arbitrage, or real-time analytics, developers must optimize both their infrastructure and client-side logic. Here are few of the best practices that Shyft suggests.
Minimize Your Ping
Latency starts at the network level. No matter how optimized your code is, the speed of light remains the ultimate bottleneck. The single most impactful action you can take to minimize latency is to achieve geographical co-location with Shyft gRPC's endpoint.
Aim for a network latency of 0-1 milliseconds (ms) between your client application and Shyft gRPC URL.
Here are the data centers Shyft use for different regions which you can co-locate with.
Amsterdam: Cherry Servers
Frankfurt: Cherry Servers, Latitude
London: Latitude
New York: Latitude
Ashburn: Latitude
Its still possible to achieve 1-2 ms latency without co-locating. Make sure you are in the same region as the gRPC URL you are connecting to. Use standard network tools like ping
or mtr
to measure your latency.
Distribute Load Across Multiple gRPC Clients
Streaming multiple high-load addresses (e.g., Meteora DLMM, Pumpfun, etc) in a single Geyser subscribe
request can quickly overwhelm a single client connection. This can lead to
A backlog of messages waiting to be processed at the network layer within the client's single consumer thread. The client may fall too far behind, causing the provider or client library to disconnect to prevent unmanageable backlogs.
Shyft suggests splitting high-load addresses across multiple gRPC clients and distribute their processing across separate CPU cores/threads.
For extremely high-volume programs (e.g., DEXs, Pump.fun), divide the stream load across multiple gRPC clients. This horizontally scales your processing to prevent a single client from becoming a bottleneck.
Moreover, ensure different streams are processed on different threads or cores (or using an asynchronous event loop) to decouple I/O (receiving the message) from CPU-bound work (deserializing, filtering, and executing business logic). This prevents slow processing logic from delaying the consumption of new messages off the network buffer.
Connection Efficiency
While horizontal scaling is necessary for high-load programs, over-fragmenting your connections for moderate-load addresses can quickly hit your Shyft connection limits.
Dont create a new connection for token, pools or wallet addresses. Club them together in a single subscribe request.
For moderate-load addresses (e.g., individual tokens, liquidity pools, or user wallets), it is significantly more efficient to club multiple addresses into a single Geyser subscribe
request. Instead of having a new connection for each individual address.
Learn how to Modify your gRPC subscribe request to add or remove addresses.
Expand gRPC Max Decoding Message Size
Yellowstone gRPC clients have a default maximum size for a single incoming message, which is 4 MB (4194304 bytes). If you are streaming account update or block udpates there are chances that you can hit the 4 MB limit.
Configure your gRPC client while initialising to avoid hitting the 4 MB message limit.
To avoid this, you need to configure your gRPC client initialisation
const client = new Client(shyft_grpc_url, shyft_grpc_token, {
"grpc.max_receive_message_length": 1024*1024*1024
});
Last updated
Was this helpful?