โ†
Previous Module
Wallet Connect Demo

๐Ÿšฆ Rate Limiting: Infura, Alchemy, QuickNode

Understand RPC provider limits and batching techniques

Communicate with blockchain nodes programmatically

๐Ÿšฆ Rate Limiting & Optimization

RPC providers rate-limit everything. Free tiers allow 10-100 requests/second. Paid tiers scale to thousands. Exceed limits and you get HTTP 429 errors. Production dApps must optimize RPC usage: batch requests, cache data, use WebSockets, and implement proper retry logic. Let's learn how to stay under limits and reduce costs by 90%.

๐ŸŽฎ Interactive: Rate Limit Calculator

Adjust your application's request rate and provider limits to see if you exceed rate limits, calculate costs, and understand optimization needs.

10
Light usage (simple dApp)
100,000
Free tier (Infura, Alchemy)
Daily Usage
864,000
10/sec ร— 86,400 sec
Status
โŒ Over Limit
100% utilized
Monthly Cost
$0.00
Free tier
โš ๏ธ Warning: Exceeding Rate Limit

Your application will receive HTTP 429 errors. You need to either upgrade to a higher tier (12 req/sec) or optimize your RPC usage (caching, batching, WebSockets).

โšก Optimization Strategies

๐Ÿ“ฆ
Batch Requests

Send multiple RPC calls in one HTTP request. Instead of 10 separate requests (10 credits), send 1 batched request (1 credit). Reduces usage by 90% for read-heavy apps.

const batch = [
  { method: 'eth_getBalance', params: [...] },
  { method: 'eth_call', params: [...] }
];
await provider.send(batch);
๐Ÿ’พ
Cache Immutable Data

Block data never changes. Cache blocks, receipts, and logs in Redis/database. First request hits RPC, subsequent requests hit cache. Saves 99% of requests for historical data.

const cached = await redis.get(blockNumber);
if (cached) return cached;
const block = await provider.getBlock(blockNumber);
await redis.set(blockNumber, block);
๐Ÿ”Œ
Use WebSocket Subscriptions

For real-time data (new blocks, pending txs), use eth_subscribe via WebSocket. Node pushes updates to you. No polling needed. Saves 99% of requests vs polling every second.

const ws = new WebSocket(wssUrl);
ws.send({ method: 'eth_subscribe', 
  params: ['newHeads'] });
// Receive block updates automatically
๐ŸŽฏ
Use Multicall Contracts

Query multiple contracts in one eth_call. Multicall aggregates 100 calls into 1. Popular for token prices, balances. Used by Uniswap, 1inch. Saves 99% of requests.

const multicall = new Multicall(provider);
const results = await multicall.aggregate([
  token1.balanceOf(wallet),
  token2.balanceOf(wallet), // 100 more
]);

๐Ÿ“Š Provider Comparison

ProviderFree TierGrowth TierFeatures
Infura100K/day
~1 req/sec
$50/mo
5M/day
Archive, WebSocket, IPFS
Alchemy300M/mo
~100 req/sec
$199/mo
1B/mo
Enhanced APIs, NFT API, Webhooks
QuickNodeNone$49/mo
50M/mo
Dedicated nodes, 20+ chains
Ankr500M/mo
~200 req/sec
Pay-as-go
$10/50M
Public RPC, 50+ chains

๐Ÿ’ก Key Insight

RPC costs scale with poor optimization, not traffic. A naive dApp making 1,000 requests for data that could be batched into 10 requests wastes 99% of its quota. Professional dApps use 10-100x fewer RPC calls than amateur ones through batching, caching, WebSockets, and Multicall contracts. This isn't just about costโ€”it's about reliability. When you hit rate limits during a traffic spike, your dApp breaks. Optimization isn't optional for production apps.

โ† Error Handling