Frontend vs Backend RPC call performance

Hello,
I’m having trouble using multicall contract calls, seems like the same call including 7 eth_calls (I’m using the same data for benchmarking) takes me:

  • 800 ms using multicall with Infura
  • 200 ms using batch call with Infura
  • 200 ms using multicall with super random competitor RPC
  • 200 ms using batch call with super random competitor RPC

Could it be something with my config ?

at the moment I’m using axios without any particular configuration.

Regards

1 Like

Apparently the difference in fact comes from the source of the call. When I call the RPC from the frontend the response times are reasonable, but when called from the backend (nextjs API endpoint) the times are 4x longer. The time measured - is only the time required to perform POST call with axios.

  const multicallResponse = await axios.post<string, AxiosResponse<{ result: string }>>(
    provider.connection.url,
    callBody,
    config,
  )

What can be done to improve the response times? Does Infura require any particular headers or other call settings?

image

Hey, is your frontend and backend running on the same machine or location ?

Yes and yes.
I’ve tested it with nextjs locally and on AWS with same results.