Case Study: How Lucidity Optimized Their Infura Usage to Save Time and Money

Reading blockchain data is necessary for Web3 applications to operate on the networks they interact with. For Ethereum, one way this can be done is via open-source protocol, JSON-RPC (2.0). This protocol provides a simple interface for interacting with nodes in the Ethereum network. However, because JSON-RPC was not built to be a query layer, it can be really difficult to use to pull useful data off the blockchain. The protocol returns raw output and often calls data that the Ethereum client doesn’t need (over-fetching). It may also require a dapp to make several calls to retrieve specific data (under-fetching). This can result in large call volumes and increased operating costs for developers.

In this post, we sit down with Miguel Morales from blockchain-based marketing analytics company Lucidity. Miguel shares how Lucidity optimized their Infura usage to dramatically reduce their call volume, saving time and money in the process.

Can you describe what Lucidity is for those who aren’t familiar with your company?

Morales: “Lucidity develops products, protocols and solutions for agencies and advertisers to bring trust and transparency to programmatic advertising. Our core service provides advertisers with a unified view of their most important campaign data, validated by signals from across the digital advertising supply chain.”

As a blockchain-based platform, your product operates on Web3 infrastructure. How was Lucidity ‘doing infrastructure’ before you started using Infura?

Morales: “We used to host our own Ethereum nodes on our own cloud infrastructure. This required us to spend time maintaining the node and we were forced to re-synchronize if there were issues. This is particularly challenging when working with some of the Ethereum test-nets such as Ropsten. This would cause us to spend valuable engineering resources trying to maintain something that was not core to our product offering. It’s like trying to maintain your own cloud infrastructure. It’s just not something we wanted to deal with.”

Is that what drew you to Infura?

Morales: “Once it became apparent that we did not want to deal with maintaining our own node, we started to look for good public nodes. We’d heard about Infura and checked out their offering. It was pretty simple to point our app to Infura, instead of pointing it at our own node. That’s all it took. Infura’s hosted Ethereum solution was a seamless replacement to our hosted node. We didn’t have to deal with maintaining the node and we also obtained high availability and automatic failover.”

How does Lucidity use Infura to interact with the Ethereum blockchain?

Morales: “Our application communicates with the Ethereum blockchain entirely through Infura. We use it to submit and retrieve transactions, launch and manage smart contracts, and listen for events emitted through those smart contracts.”

You’ve managed to reduce your call volume without reducing the quality of your product. How did you optimize your Infura usage to achieve this outcome? I’m sure there are quite a few devs out there who would be eager to know!

Morales: “We implemented the following changes to optimize our usage:

  1. Now, our application continuously checks the current block and retrieves transactions from historical blocks;
  2. Our application was very heavy on reads and light on writes, so we thought using ‘cached reads’ would be a good approach;
  3. We developed a small application to act as a thin proxy between our application and Infura. The proxy application is simple and it only hits Infura/Ethereum on the initial call. All future calls for the same block or transaction are then returned from cache;
  4. Writes are automatically forwarded to Infura. This was a seamless optimization. We simply had to point our application to our proxy and everything worked without any changes to our application.”
A screenshot of Lucidity’s Infura dashboard showing the reduction in call volume achieved over a five day period

What kind of efficiency gains did you make after implementing these changes?

Morales: “We were able to reduce calls to Infura and save on costs. And because the proxy uses an in-memory cache, we didn’t need to call the Ethereum blockchain every time. Those requests became faster and more reliable. It also meant that we didn’t have to switch to web socket implementations which would have been costly. We were able to keep our polling architecture while still enjoying the benefits of Infura.”

To learn more from top Web3 dapps like Lucidity , or for more tips, tricks and case studies, subscribe to the Infura newsletter.

Need more request volume and direct support? Check out Infura+ to pick the right plan for your project.