Overview
Backends are the upstream Solana RPC nodes that the router forwards requests to. Each backend is defined with a unique label, URL, weight for load balancing, and optional WebSocket endpoint.Backend Structure
Backends are defined as an array in the TOML configuration using the[[backends]] notation:
Configuration Parameters
Unique identifier for the backend. Used in metrics, logs, and method routing.Validation Rules:
- Cannot be empty
- Must be unique across all backends
- Referenced by method routes (if configured)
HTTP(S) endpoint for the RPC node.Examples:
https://api.mainnet-beta.solana.comhttps://solana-api.comhttp://127.0.0.1:9090(local testing)
Both HTTP and HTTPS URLs are supported. Use HTTPS for production deployments.
Relative weight for weighted random load balancing. Higher weights receive more traffic.Validation: Must be greater than 0Example: A backend with
weight = 10 receives twice as much traffic as one with weight = 5WebSocket endpoint for subscription-based RPC methods (optional).Examples:
wss://api.mainnet-beta.solana.comws://127.0.0.1:9091(local testing)
If omitted, WebSocket requests to this backend will not be supported. The router’s main WebSocket endpoint runs on
port + 1.Load Balancing Behavior
The router uses weighted random selection to distribute requests across healthy backends:- Only healthy backends (passing health checks) are eligible
- Each backend’s probability is
weight / sum_of_all_healthy_weights - Selection is random but statistically matches the weight distribution
Example
- primary: 10/(10+5+2) = ~59% of requests
- secondary: 5/(10+5+2) = ~29% of requests
- tertiary: 2/(10+5+2) = ~12% of requests
If a backend fails health checks, it’s removed from the pool and traffic is redistributed among healthy backends.
WebSocket Configuration
WebSocket support is optional per backend:Validation Rules
All backends are validated on startup:At least one backend must be configured
All labels must be unique (no duplicates)
All labels must be non-empty strings
All weights must be greater than 0
All URLs must be valid (enforced by TOML parsing)
src/config.rs:63-122:
Common Patterns
Single Backend (Simple Proxy)
Primary + Backup
Equal Distribution
Local Testing
debug_config.toml:4-7).
Integration with Method Routing
Backend labels are referenced in method-based routing:Monitoring
Backend health and performance metrics are exposed via Prometheus:rpc_backend_health{backend="[label]"}- Current health status (1 = healthy, 0 = unhealthy)rpc_requests_total{backend="[label]"}- Total requests routed to this backendrpc_request_duration_seconds{backend="[label]"}- Request latency to this backend