JSON-RPC Batching Explained: Fewer Round Trips, Real Limits
If your dApp feels slow against a fast RPC endpoint, the problem is rarely the endpoint. It's often that you're making fifty separate HTTP requests when you could be making one.
Yet plenty of production code still does this — including code written by experienced engineers, often against top-tier RPC providers. The fix is older than Ethereum mainnet, built into the JSON-RPC 2.0 spec from day one, and supported by every reasonable provider. It's called batching, and it's one of the highest-leverage changes you can make to backend latency before you think about provider choice or network routing.
But batching is also where a lot of applications discover a new failure mode: the batch limit. A request that works one call at a time can fail as a group, and many providers now bill or rate-limit each call inside the batch rather than the HTTP request as a whole. This post covers what batching actually does, how current client libraries handle it, and the limits that matter in production.
The problem in one paragraph
Every JSON-RPC call costs you a TLS handshake (already amortized if you keep connections alive), one HTTP round-trip (~50–200ms depending on your client's distance from the provider), and the actual RPC processing time at the node. For a single call, the network round-trip usually dwarfs the processing. So if you make 50 sequential calls — say, fetching balances for 50 token contracts — you pay the round-trip cost 50 times. That's the latency you feel as a user.
Batching lets you pack many JSON-RPC calls into one HTTP request body, and the server returns one HTTP response containing all the results. You pay the round-trip cost once. The node still processes the 50 calls, but can do so concurrently or in a tight loop.
The mechanics
A normal JSON-RPC request looks like this:
{ "jsonrpc": "2.0", "id": 1, "method": "eth_getBalance", "params": ["0xabc...", "latest"] }
A batched request is just an array of those objects:
[
{ "jsonrpc": "2.0", "id": 1, "method": "eth_getBalance", "params": ["0xabc...", "latest"] },
{ "jsonrpc": "2.0", "id": 2, "method": "eth_getBalance", "params": ["0xdef...", "latest"] },
{ "jsonrpc": "2.0", "id": 3, "method": "eth_chainId", "params": [] }
]
The response is an array of the same shape:
[
{ "jsonrpc": "2.0", "id": 1, "result": "0x12a05f200" },
{ "jsonrpc": "2.0", "id": 3, "result": "0x1" },
{ "jsonrpc": "2.0", "id": 2, "result": "0x4563918244f40000" }
]
Two things to notice:
- Responses can come back in any order. Always match by
id, never by array position. - Each call can be a different method. A single batch can mix
eth_getBalance,eth_call, andeth_chainIdfreely. They're independent. - A batch can fail as a whole or per item. Check both the HTTP status and every object in the response array; a
200can still contain method-level errors.
Where ethers.js and viem already do this
ethers v6
ethers v6's JsonRpcProvider batches by default. There is no separate BatchProvider class to import. Calls queued within the same short window are coalesced into one HTTP request, and you can tune the window and count with the provider options:
import { JsonRpcProvider } from "ethers";
const provider = new JsonRpcProvider(
"https://rpc.swiftnodes.io/rpc/eth?key=YOUR_KEY",
undefined,
{
batchStallTime: 10, // wait up to 10ms for more calls
batchMaxCount: 20, // cap a batch at 20 calls
},
);
// These calls are batched into one HTTP request behind the scenes.
const balances = await Promise.all(
addresses.map((a) => provider.getBalance(a)),
);
The defaults are batchStallTime: 10 ms, batchMaxCount: 100 and a target batchMaxSize of 1 MB. The count cap matters on a free plan with a 20-call batch limit; a larger batch is rejected rather than silently split.
viem
viem's http() transport does not batch by default. You opt in with batch:
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http("https://rpc.swiftnodes.io/rpc/eth?key=YOUR_KEY", {
batch: {
wait: 10, // wait up to 10ms for more calls
batchSize: 20, // never send more than 20 calls at once
},
}),
});
const balances = await Promise.all(
addresses.map((address) => client.getBalance({ address })),
);
The default batchSize is 1,000, which is larger than many providers' limits. Set it to your provider's cap rather than discovering the cap in production.
web3.py
web3.py exposes batching through w3.batch_requests(); it is not automatic:
from web3 import AsyncWeb3, AsyncHTTPProvider
w3 = AsyncWeb3(
AsyncHTTPProvider("https://rpc.swiftnodes.io/rpc/eth?key=YOUR_KEY")
)
async with w3.batch_requests() as batch:
for address in addresses:
batch.add(w3.eth.get_balance(address))
results = await batch.async_execute()
The web3.py docs also note that asyncio.gather() with concurrent single requests can be faster than an async batch because batch encoding and decoding have overhead. Batch when you need one HTTP round trip or a provider-side batch; do not assume it always wins.
When batching does not help
Auto-batching only kicks in for calls made close together in time. Patterns that break it:
- Sequential
awaitchains.await provider.getBalance(a); await provider.getBalance(b);runs one at a time, so the batcher sees separate intents. UsePromise.allor the equivalent. - Long synchronous work between calls. If you do CPU-heavy processing between two
awaits, you've blown past the batch window. - Multiple provider instances. Each provider has its own batcher. Two instances can produce two HTTP requests even if you
Promise.allagainst both. - A slow call mixed with fast ones. The HTTP response cannot complete until every item in the batch is done. A 10,000-block
eth_getLogscall will hold up 19 balance reads sitting behind it.
The fix is usually the same: reuse one provider, collect independent fast calls up front, and keep slow or long-running queries in a separate request.
The limits that actually bite
SwiftNodes
The free plan allows 20 calls per JSON-RPC batch, with up to 20 HTTP requests per second and 250,000 requests per month. A batch of 21 returns HTTP 400 with a JSON-RPC error explaining the limit; split it or upgrade to a paid plan.
Paid plans do not have a separate per-batch call count in the same way, but every call in the batch counts toward your plan's requests per second and monthly usage. A batch that carries more calls than your per-second budget can absorb can be rejected as a whole with a 429, not split into smaller batches. Since October 2, 2026, batch calls are counted per call for usage, quota and rate limits; before that, a batch of 100 counted as one request.
That distinction is important when you compare providers:
- If a provider bills per HTTP request, batching can reduce the bill as well as latency.
- If a provider bills per call, batching only reduces network overhead; the 20 calls still cost 20 calls.
- If a provider rate-limits per call, a large batch can consume a whole second of budget in one request.
Other providers publish batch caps in the hundreds or low thousands, and they differ on whether over-limit batches are split, truncated or rejected. Read the provider's current docs rather than assuming a fixed “100 is safe” number.
The other ceilings
- HTTP request body size. Calls with large
params(heavyeth_callpayloads, big log filters) can hit the body limit before the call-count limit. - One slow call slows the whole batch. See above. Split mixed-latency work.
- Free-plan method limits. On SwiftNodes, free
eth_getLogscovers at most 100 blocks per request, and trace/debug methods need a paid plan. A batch does not bypass those per-method rules.
When to use multicall instead
If you're making many eth_call requests against contracts on an EVM chain, you have a third option that's often better than JSON-RPC batching: the Multicall3 contract deployed at 0xcA11bde05977b3631167028862bE2a173976CA11 on essentially every EVM chain.
Multicall3 lets you aggregate many contract reads into a single eth_call that the chain executes atomically. Instead of:
- 50 individual
eth_calls → 50 entries in a JSON-RPC batch → 1 HTTP round-trip → 50 calls on the node
you get:
- 1
eth_callto Multicall3 → 1 JSON-RPC request → 1 HTTP round-trip → 1 call that internally fans out to 50 reads
That's cheaper for the node and for you. viem has built-in multicall support; ethers can use it through a third-party multicall helper. It is worth reaching for when you're making more than a handful of contract reads at the same block height.
Measure it on your own traffic
There is no universal “batching is 5× faster” number. The gain depends on your round-trip time, batch limit, method mix and provider queueing. Measure the patterns against the endpoint you actually use:
- Pick 20 calls that are independent and hit the same block.
- Time them sequentially, with
Promise.allas separate HTTP requests, and as one batch. - Repeat at least 20 times and compare p50 and p95 — not a single run.
- Repeat with your largest realistic batch, and with a mixed-latency batch, to find the point where the slowest call dominates.
If your provider bills per call, also price the batch in your usage dashboard. A lower wall-clock number does not necessarily mean a lower bill.
The takeaway
If you're using ethers v6 with Promise.all, you're probably already getting batching by default. If you're using viem and didn't add batch, you're sending separate HTTP requests. If you're using web3.py, batching is explicit.
But size the batch to the plan. On SwiftNodes Free that means 20 calls, not 100. On paid plans, every call counts toward your rate and usage, so a bigger batch is not free throughput. And when you're making many contract reads at one block, Multicall3 is often the better tool entirely.
SwiftNodes supports JSON-RPC batching on every supported chain, including Ethereum, Base, Arbitrum, Polygon, and Optimism. The free plan allows 20 calls per batch; paid plans count each call toward your plan rate. See rate limits or get a free API key.
John Sullivan covers RPC infrastructure, node operations, and multi-chain development at SwiftNodes — what it actually takes to keep endpoints fast, fresh, and reliable across EVM and non-EVM networks.
Related posts
- Multicall3 Cheat Sheet: One eth_call Does It All
Multicall3 lives at the same address on every EVM chain and turns 100 contract reads into one RPC call. Here's how it actually works, when to use which variant, and the gotchas that bite people in production.
- How eth_getLogs Range Caps Bite in Production
Your indexer works fine until it hits a single dense block range, then everything stops. Here's the cap mechanics across providers, the adaptive chunking pattern that actually works, and the code to do it right.
- How Old Is 'finalized'? We Measured 62 Chains
eth_getBlockByNumber('finalized') ranges from instant to four hours across 62 EVM chains; five give no answer, one returns genesis. The table and code.