Overview
Method-based routing allows you to send specific RPC methods to designated backends, overriding the default weighted random load balancing. This is useful for:- Routing heavy queries to archive nodes
- Sending time-sensitive methods to low-latency nodes
- Isolating experimental methods to test backends
- Optimizing backend resource utilization
Configuration
Method routes are defined in the[method_routes] section:
The entire
[method_routes] section is optional. If omitted, all methods use weighted random load balancing.Syntax
Key-value pairs mapping RPC method names to backend labels.Format:
method_name = "backend_label"Requirements:- Method name must match exact Solana RPC method (case-sensitive)
- Backend label must reference an existing backend from
[[backends]]
Validation
Method routes are validated on startup:All referenced backend labels must exist in the
backends arrayBackend labels are case-sensitive and must match exactly
Invalid routes prevent router startup
src/config.rs:101-109:
Routing Behavior
With Method Route Configured
- Request with method
getSlotarrives - Router checks
[method_routes] - Finds
getSlot = "mainnet-primary" - Routes request directly to backend labeled
"mainnet-primary" - No load balancing - always uses specified backend
Without Method Route
- Request with method
getBalancearrives - Router checks
[method_routes] - No route configured for
getBalance - Falls back to weighted random load balancing across all healthy backends
Health checks still apply. If the designated backend is unhealthy, the request will fail even with method routing configured.
Common Use Cases
Archive Node Routing
Route historical queries to nodes with full history:Low-Latency Routing
Send time-sensitive methods to fastest node:Backend Isolation
Isolate specific methods during testing:Specialized Backend Features
Route to backends with specific capabilities:Complete Example
Fromconfig.example.toml:1-28:
getSlotalways routed to"mainnet-primary"- All other methods load balanced between
"mainnet-primary"(67% weight) and"backup-rpc"(33% weight)
Common Solana RPC Methods
Popular methods you might want to route:State Queries
getAccountInfo- Account data retrievalgetBalance- Account balancegetProgramAccounts- Program-owned accounts (heavy)getMultipleAccounts- Batch account data
Block & Transaction Queries
getBlock- Block data (archive)getTransaction- Transaction details (archive)getRecentBlockhash- Latest blockhashgetSlot- Current slot number
Subscription Methods (WebSocket)
accountSubscribe- Account change notificationslogsSubscribe- Transaction log streamingslotSubscribe- Slot change notifications
Cluster Info
getEpochInfo- Current epoch datagetBlockHeight- Current block heightgetHealth- Node health statusgetVersion- Node version info
See Solana RPC API for complete method list.
Monitoring Method Routes
You can track routing behavior using the standard request metrics:Best Practices
Route heavy queries
Send
getProgramAccounts and other heavy methods to dedicated backends to prevent impacting light queries.Use archive nodes for history
Route
getTransaction, getBlock, and getConfirmedBlock to nodes with full historical data.Keep health checks simple
Don’t route the health check method (
getSlot by default) - let it use load balancing to test all backends.Test routing changes
Verify method routes in development before deploying. Invalid backend labels prevent startup.
Monitor backend load
Watch metrics to ensure routed methods don’t overwhelm designated backends.
Document your routing
Comment your method routes to explain why specific methods go to specific backends.
Troubleshooting
Validation Error on Startup
Error:Method route 'getSlot' references unknown backend label 'fast-node'
Solution: Ensure backend label exists in [[backends]] array:
Method Always Fails
Symptoms: Specific method returns errors while others work Solutions:- Check if designated backend is healthy:
curl http://localhost:28901/metrics | grep backend_health - Verify backend supports the method
- Test backend directly:
curl -X POST [backend_url] -d '{"jsonrpc":"2.0","id":1,"method":"[method]"}' - Check backend logs for errors