Improving RPC Performance with Compression

Adding an Accept-Encoding: gzip, br header to JSON-RPC requests can reduce transfer size and deliver up to a 70% speed improvement for responses over 100 KB

Adding an Accept-Encoding: gzip, br header to JSON-RPC requests can reduce transfer size and improve speed by up to 70% for responses over 100 KB. This applies to Solana, Arbitrum, Ethereum, Polygon, and other supported chains.


Why This Matters

By default, if your requests do not specify a compression method, the response is sent uncompressed. For large blockchain data sets, like Solana blocks, this can mean several megabytes per call.

This results in:

  • Higher bandwidth usage: potentially tens of MB per call
  • Slower responses: longer download times
  • Increased network load: more strain on client and server

📘

Info

Some Solana blocks can exceed 100 MB uncompressed, which significantly slows down data transfer.


Benefits of Enabling Compression

  • Faster response times: less data over the network
  • Lower bandwidth usage: save resources and reduce costs
  • Better performance at scale: ideal for high-volume workloads

How to Enable Compression

Add the following HTTP header to your JSON-RPC requests:

Accept-Encoding: gzip, br
  • gzip: supported by most HTTP clients and servers
  • br (Brotli): usually provides the best compression ratio but requires client support

Response Time and Size Comparison

Example request with compression:

curl --location 'https://solana-mainnet.gateway.tatum.io' \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: {YOUR_API_KEY}' \
  --header 'Accept-Encoding: gzip, br' \
  --data '{
    "jsonrpc":"2.0",
    "id":1,
    "method":"getBlock",
    "params":[214847800]
}'
#Response time: 700ms
#Response size: 650 KB

Example request without compression:

curl --location 'https://solana-mainnet.gateway.tatum.io' \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: {YOUR_API_KEY}' \
  --data '{
    "jsonrpc":"2.0",
    "id":1,
    "method":"getBlock",
    "params":[214847800]
}'
# Response time: 1.6s
# Response size: 5.33 MB