keepcalculator

06 Numbers and Powers

Check Solana RPC Latency From Your Location

Card No. 06·81933 · Updated · Standard formula, shown below

This guide shows you how to measure the network latency between your computer and a Solana RPC endpoint, helping you choose the fastest provider for trading, staking, or running dApps. You’ll learn several methods, from simple ping commands to more accurate JSON-RPC timing, and how to interpret the results. No special software is required beyond a terminal or command prompt.

What You’ll Need

  • A computer with internet access (Windows, macOS, or Linux)
  • A terminal or command prompt (on Windows, use PowerShell or CMD)
  • Basic familiarity with typing commands
  • Optional: a list of RPC endpoints you want to test (you can use public ones like api.mainnet-beta.solana.com or provider-specific URLs)

Step-by-Step

  1. Identify the RPC endpoints you want to test.

    Start with a few public endpoints or those from your preferred provider. For example:

    • api.mainnet-beta.solana.com (official public endpoint)
    • solana-api.projectserum.com (community endpoint)
    • Provider-specific URLs from services like QuickNode, Alchemy, or Helius (you’ll have these in your dashboard).

    Note: The official endpoint has rate limits and may not be the most reliable for production, but it’s fine for testing.

  2. Open your terminal or command prompt.

    On Windows, press Win + R, type cmd, and press Enter. On macOS, open Terminal from Applications/Utilities. On Linux, use your preferred terminal emulator.

  3. Run a basic ping test (ICMP).

    Ping measures the round-trip time for small packets. Type:

    ping api.mainnet-beta.solana.com

    Note the average latency in milliseconds (ms). This is a rough indicator, but it doesn’t reflect the actual HTTP request time to the RPC server, because ICMP may be prioritized or blocked.

  4. Measure HTTP latency with curl.

    Use curl to time a simple JSON-RPC request. First, test the official endpoint:

    curl -o /dev/null -s -w "Total time: %{time_total}s\n" -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"getHealth"}' https://api.mainnet-beta.solana.com

    The output shows the total time in seconds. Multiply by 1000 to get milliseconds. Repeat for each endpoint you want to compare.

  5. Use a more precise timing method (optional).

    For a better estimate, use curl with time_starttransfer and time_connect:

    curl -o /dev/null -s -w "Connect: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n" -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"getHealth"}' https://api.mainnet-beta.solana.com

    Here, time_connect is the TCP handshake time, and time_starttransfer is the time to first byte (TTFB). The total includes the full response.

  6. Test multiple endpoints and compare.

    Run the same command for each endpoint. Record the results in a table. Lower total time generally means lower latency, but also consider consistency (run each test 3-5 times and take the average).

  7. Consider using a tool like solana CLI (optional).

    If you have the Solana CLI installed, you can use solana config set --url to set the RPC URL and then run solana cluster-version to see the response time. However, this is less precise than curl.

  8. Interpret the results.

    For a trading bot or high-frequency application, you want the lowest latency possible. For general use, anything under 100ms is acceptable. If you’re in a different region than the RPC server, latency will be higher. Choose the endpoint closest to you geographically.

Common Mistakes

  • Using ping as the sole metric. ICMP ping does not reflect the actual HTTP request time. It’s a good first check, but always use curl to measure the real RPC call.
  • Not accounting for rate limits. The official endpoint may throttle you if you send too many requests. If you get a 429 error, wait a few seconds and retry.
  • Testing only once. Latency can fluctuate. Run each test multiple times and use the average or median.
  • Forgetting to include the request body. A GET request to the RPC URL will return an error. Always use POST with the JSON payload as shown.
  • Ignoring geographic location. An endpoint in the US will have higher latency for a user in Europe. Choose endpoints that are geographically close to you.

Tips

  • Use a script to automate testing. Write a simple bash or PowerShell script that loops through a list of endpoints and prints the results in a readable format.
  • Test at different times of day. Network congestion varies. Test during peak hours and off-peak hours to get a full picture.
  • Check for WebSocket latency. If your app uses WebSocket connections (common for real-time updates), test the WebSocket endpoint (e.g., wss://api.mainnet-beta.solana.com) using a tool like websocat or a small script.
  • Consider using a load balancer. Some providers offer multiple endpoints under one URL. Test each individual endpoint if possible.
  • Keep a record of results. Save the output to a file for future reference, especially if you’re comparing providers.

Troubleshooting

  • curl: (6) Could not resolve host — Check your internet connection and DNS settings. Try using the IP address directly if you have it.
  • curl: (7) Failed to connect — The endpoint may be down or blocking your IP. Try a different endpoint or check if the provider has a status page.
  • HTTP 429 Too Many Requests — You’ve hit the rate limit. Wait a bit and reduce the frequency of your requests. Use a different endpoint if available.
  • HTTP 403 Forbidden — The endpoint may require an API key. Add your key as a header: -H "Authorization: Bearer YOUR_KEY".
  • JSON error — Make sure your request body is valid JSON. Use single quotes around the data in the curl command, and escape double quotes correctly.
  • High latency even with a close endpoint — Check your local network, VPN, or firewall. Try disabling VPN or using a wired connection.

Frequently Asked Questions

What is a good RPC latency for Solana?

For most applications, under 100ms is fine. For high-frequency trading or arbitrage, aim for under 50ms. Latency above 200ms may cause noticeable delays.

Why is my ping low but curl time high?

Ping uses ICMP, which is often handled by network hardware and may not reflect the server’s application processing time. The curl time includes TCP handshake, TLS negotiation, and the actual JSON-RPC processing, which is more representative.

Can I test latency from a different location?

Yes, you can use a cloud VM or a service like AWS EC2 in a specific region to run the same tests. This is useful if you plan to deploy your application in that region.

Does the Solana CLI have a built-in latency test?

The CLI doesn’t have a dedicated latency command, but you can use solana config set --url and then solana cluster-version to see the response time, which includes the RPC round trip.

Should I use a public or private RPC endpoint?

Public endpoints are free but have rate limits and may be slower. Private endpoints (from providers) offer higher throughput and reliability, but require a subscription. For production, consider a private endpoint.

How often should I re-test latency?

Network conditions change. Re-test monthly or whenever you experience performance issues. Also re-test if you move to a new location or change internet providers.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →