Solana Geyser gRPC - gRPC Latency Test

This guide will show you how to test the latency of the Solana Geyser gRPC server.

Prerequisites

Install SLV CLI:
bash
curl -fsSL https://storage.slv.dev/slv/install | sh

Test gRPC Latency

You can easily test the latency of the Solana Geyser gRPC server with the following command:
bash
slv check grpc --help
Usage:   slv check grpc
Version: 0.9.0

Description:

  Check gRPC endpoint

Options:

  -h, --help              - Show this help.
  --endpoint  <endpoint>  - gRPC endpoint URL
  --token     <token>     - Token for authentication
If you don't have a Geyser gRPC Access, please refer to the Geyser gRPC Quickstart guide.

Run the latency check

Shared gRPC endpoints no longer require an x-token. Pass --token none and test your regional endpoint directly:
bash
  ~ slv check grpc --endpoint http://grpc-ams1.erpc.global --token none
Checking gRPC endpoint: http://grpc-ams1.erpc.global
Current latency: 540 ms, slots: 0
Avg latency: 540 ms
Current latency: 962 ms, slots: 1
Avg latency: 751 ms
Current latency: 394 ms, slots: -1
Avg latency: 632 ms
Current latency: 776 ms, slots: 0
Avg latency: 668 ms
Current latency: 1157 ms, slots: 1
Avg latency: 765.8 ms
Current latency: 529 ms, slots: 0
Avg latency: 726.3333333333334 ms
Current latency: 891 ms, slots: 1
Avg latency: 749.8571428571429 ms
Current latency: 249 ms, slots: -1
Avg latency: 687.25 ms
The test will then proceed to check the latency of the Geyser gRPC server.
You can stop the test by pressing Ctrl + C.

Reference: Understanding gRPC Latency

When measuring gRPC latency, you might see values of over one second. This can initially feel "slow," but remember that Solana’s block time is only recorded at the second level—milliseconds are truncated.

Connecting in the Same Region

First, ensure your server is located in the same region as the gRPC endpoint. For instance, if you’re connecting to grpc-ams1.erpc.global, you should place your server in Amsterdam as well to minimize network latency.

Why You Might See “Over 1 Second” Latency

Consider a transaction that actually occurs at 07:46:46.900, but Solana records it as 07:46:46.000. If you receive it at 07:46:47.200, a straightforward calculation yields:
text
(Receive Time) - (Block Time)
= 07:46:47.200 - 07:46:46.000
= 1.2 seconds
At first glance, this looks like 1.2 seconds of latency. However, because the transaction really happened at 07:46:46.900, the actual latency is only about 300ms: 07:46:47.200 - 07:46:46.900 = 0.3 seconds.

Subtracting 500ms as an Approximation

Because Solana rounds down to the nearest second, we don’t know exactly where in that second the transaction took place. A reasonable approximation is to assume a midpoint (500ms), so the formula becomes:
text
(Receive Time) - (Block Time + 0.5 seconds)
While not perfectly precise, this helps offset the missing millisecond data, providing a closer estimate of actual gRPC latency.
By keeping these considerations in mind, you can more accurately gauge Solana Geyser gRPC latency. The second-level time recording on Solana necessitates factoring in potential rounding discrepancies, as well as ensuring proper server and endpoint placement to reflect real-world performance.