Overview
Lasso RPC supports JSON-RPC batch requests, allowing you to send multiple RPC calls in a single HTTP request. This reduces network overhead and improves throughput for bulk operations.Batch Request Format
Send an array of JSON-RPC request objects instead of a single object.Single Request
Batch Request
Basic Example
Responses are returned in the same order as the requests, preserving the request array order.
Batch Size Limit
Maximum 50 requests per batch (configurable viamax_batch_requests application config).
Exceeding the limit returns an error:
Advanced Examples
Account Balance and Nonce
Multiple Contract Calls
Mixed Methods
Historical Log Queries
Batch Requests with Strategies
Batch requests work with all routing strategies.Fastest Strategy
Provider Override
Profile-Scoped
Error Handling
Batch requests return partial results if some requests fail.Mixed Success and Error
Invalid Request in Batch
Performance Optimization
Lasso optimizes batch requests with zero-copy passthrough when possible.Passthrough Conditions
Batch responses use raw bytes directly from upstream providers when:- All requests succeed
- All responses are
Response.Successstructs - Observability metadata is not requested in body (
include_metanot set tobody)
Observability with Batches
X-Lasso-Request-ID: Request tracking IDX-Lasso-Meta: Metadata for first successful request
For batch requests, observability metadata in headers represents the first request with a valid context. Use
include_meta=body for per-request metadata (degrades performance).Request IDs
Each request in a batch must have a uniqueid field for proper response correlation.
Good Practice
Bad Practice
Best Practices
Batch Size
- Keep batches under 50 requests (hard limit)
- Optimal batch size: 10-20 requests for balance between throughput and latency
- Larger batches may trigger provider rate limits
Request Ordering
- Group related requests together
- Place high-priority requests first
- Consider response time variance
Error Recovery
- Check each response individually for errors
- Implement retry logic for failed requests
- Don’t assume all-or-nothing success
Use Cases
Good for batching:- Multiple account balances
- Multiple contract read calls
- Block metadata queries
- Token holder data
- Subscription requests (
eth_subscribenot supported over HTTP) - Write operations (not supported)
- Single high-priority request (no latency benefit)
Configuration
Configure batch size limit in your application config:50