Moonwell relies heavily on real-time data to provide users with accurate information about their assets and the broader market. Our application performs numerous multicalls and background polling every few seconds to update data across dozens of smart contracts and user wallets. This involves fetching the balanceOf all collateral and underlying tokens for various markets, resulting in a staggering number of RPC requests. The high volume of these requests not only posed technical challenges but also led to significant RPC costs, impacting our operational efficiency.
To address these challenges, we adopted eRPC with the following infrastructure setup:
We utilized eRPC in-memory cache, setting a maximum of 10 million items. This shift significantly improved data retrieval speeds, aligning better with our application real-time requirements.
Our deployment strategy was pivotal in ensuring low-latency access for users worldwide. We utilized Railway, a container hosting service, to deploy eRPC instances across four strategic regions:
Each region hosts a single eRPC instance, ensuring that users are served from the nearest geographical location. To manage traffic efficiently, we employed a Cloudflare load balancer with dynamic traffic steering. This setup routes users to the closest eRPC instance based on real-time latency measurements from health checks, ensuring optimal performance.
Implementing eRPC has yielded impressive results for Moonwell: