How to test Solana RPC latency (and compare providers fairly)
Status pages and "fastest RPC" lists measure somebody else's network. What your bot or backend feels is the round trip from your server to the endpoint, for the methods you call. Here is how to measure that in a few minutes, from a single curl to a fair side-by-side.
1. One request with curl
curl can split a request into its phases. Solana RPC is JSON-RPC over HTTP POST, so any method works:
curl -s -o /dev/null -w "dns %{time_namelookup}s connect %{time_connect}s tls %{time_appconnect}s first byte %{time_starttransfer}s total %{time_total}s\n" \
https://api.mainnet-beta.solana.com -X POST -H "content-type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"getSlot"}'
dns 0.008573s connect 0.075320s tls 0.145765s first byte 0.267736s total 0.267804s
Read it as cumulative times. Here the TCP connect took about 67 ms and TLS another 70 ms, so roughly half of this 268 ms request was connection setup, which your app pays once per connection, not per request. That is the first trap: a single curl overstates latency for any client that keeps connections open (Node's fetch, @solana/web3.js and most HTTP clients do).
2. Many requests over one connection, with Node
Save this as latency.mjs and run node latency.mjs (Node 18+, no packages). It reuses one connection, waits 300 ms between calls to stay polite, and times each request to the full body, which is what your code actually waits for.
// latency.mjs: time one Solana RPC method, sequentially, and print p50 / p90.
const url = process.env.SOLANA_RPC_URL || "https://api.mainnet-beta.solana.com";
const method = process.argv[2] || "getSlot";
const times = [];
for (let i = 0; i < 10; i++) {
const t0 = performance.now();
const res = await fetch(url, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params: [] }),
signal: AbortSignal.timeout(10_000),
});
const body = await res.json(); // time to the full body, which is what your code waits for
const ms = performance.now() - t0;
if (body.error) throw new Error(`${method}: ${body.error.message}`);
times.push(ms);
console.log(`#${i + 1} ${ms.toFixed(0)} ms`);
await new Promise((r) => setTimeout(r, 300)); // stay well under the rate limit
}
const sorted = [...times].sort((a, b) => a - b);
const pct = (p) => sorted[Math.ceil((p / 100) * sorted.length) - 1].toFixed(0);
console.log(`${method}: p50 ${pct(50)} ms, p90 ${pct(90)} ms, first call ${times[0].toFixed(0)} ms`);
A run from one machine against the public endpoint:
#1 246 ms
#2 67 ms
#3 93 ms
#4 68 ms
#5 66 ms
#6 61 ms
#7 84 ms
#8 71 ms
#9 59 ms
#10 75 ms
getSlot: p50 68 ms, p90 93 ms, first call 246 ms
The first call (246 ms) carries the connection setup; the steady state is under 100 ms. Report the median and a high percentile, never the average of a handful of calls, and never only the first call.
3. Time the methods you actually use
getSlot is the cheapest call there is. A provider can be fast on it and slow on getTransaction, getSignaturesForAddress or a filtered getProgramAccounts, which touch far more data. Benchmark the mix your app sends. Some methods are not served at all on some plans: the public endpoint refuses getTokenLargestAccounts for every caller. A refusal is a result worth recording, not an error to retry (see why your Solana RPC returns 429).
4. Check slot lag, not just speed
A fast endpoint that is two slots behind gives you stale balances and blockhashes quickly. Read getSlot from every endpoint back to back, at the same commitment, and compare with the highest:
// slotlag.mjs: how far behind each endpoint is, read back to back.
const urls = (process.env.SOLANA_RPC_URLS || "https://api.mainnet-beta.solana.com").split(",");
async function slot(url) {
const res = await fetch(url, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "getSlot", params: [{ commitment: "confirmed" }] }),
signal: AbortSignal.timeout(10_000),
});
return (await res.json()).result;
}
const slots = [];
for (const url of urls) slots.push(await slot(url));
const top = Math.max(...slots);
urls.forEach((url, i) => console.log(`${new URL(url).host} slot ${slots[i]} lag ${top - slots[i]}`));
SOLANA_RPC_URLS="https://api.mainnet-beta.solana.com,https://solana-rpc.publicnode.com" node slotlag.mjs
api.mainnet-beta.solana.com slot 470716772 lag 0
solana-rpc.publicnode.com slot 470716772 lag 0
A slot is about 400 ms and the reads are sequential, so a lag of 1 can be timing. A lag that stays above 2 or 3 over several rounds is real.
5. The mistakes that make RPC benchmarks lie
- Measuring from your laptop. Your app runs in a data centre. A provider 40 ms from your desk can be 5 ms from a server in the right region. Run the test where the app runs.
- Firing requests in parallel. You end up measuring your rate limit and your own bandwidth, and you get 429s that say nothing about latency. Go one at a time with a delay.
- Counting connection setup on every call. Use a client that keeps the connection open, and look at the first call separately.
- Timing to the headers instead of the body. Large responses (
getTransaction,getProgramAccounts) take time to download. Your code waits for all of it. - One run, one time. Run at different times of day and use enough rounds that p90 means something.
- Pasting results with the API key in the URL. Helius puts the key in the query string, Alchemy and QuickNode in the path. Redact before you share.
Doing all of it in one command
solana-rpc-bench does the above for any number of endpoints: six methods over N rounds with p50/p90/max, slot lag each round, which heavier methods each endpoint serves, an optional WebSocket check, and every key redacted. It is free, MIT licensed and has no dependencies.
npx github:blixvip/solana-rpc-bench https://api.mainnet-beta.solana.com --rounds 3 --delay 500
SOLANA_RPC_URLS="https://mainnet.helius-rpc.com/?api-key=...,https://your-quicknode-url/..." npx github:blixvip/solana-rpc-bench --markdown
To keep watching over time, examples/github-action/bench.yml runs it daily in GitHub Actions and writes the Markdown report to the job summary.