How we saved more than $3M annually with Alchemy's Notify API and SDK
Game changing optimization, right under our noses
If you build in web3, you need to test your decentralized applications. But testing on actual networks costs a lot of money. So web3 builders use testnets like Goerli, where it’s free to transact and validate behavior using testnet tokens.
To get testnet tokens, you need faucets. Faucets are a critical service that “drip” free testnet tokens to builders, so they can build on testnets like Goerli or Mumbai.
At Alchemy, our mission is to bring web3 to a billion people, especially these builders. So we built faucets that make it easier for developers to build, bringing unprecedented testnet token access to all developers, while simplifying and evangelizing development in web3.
Since 2021, we’ve run the Goerli Faucet and Mumbai Faucet (as well as the deprecated Rinkeby Faucet), sending testnet tokens to developers over 3 million times!
The Goerli and Mumbai faucets currently serve so much traffic that running the faucets costs Alchemy multiple millions of dollars per year. But we recently realized a 300x cost savings, totaling over $3M a year saved.
How, you ask?
Using Alchemy Notify and the Alchemy SDK… our own products… right underneath our noses.
Read 👇 to learn how we optimized the faucets. Use our techniques to optimize your apps, too.
Problem: Excessive (and expensive) JSON-RPC calls
The two main problems with how we ran are faucets were:
Excessive getTransactionReceipt calls
Utilization of a legacy web3 library
Given the daily volume of faucet requests, the total number of RPC calls to our nodes added up fast.
Let’s dive into each problem.
1. No notification system to confirm mined transactions
Every time a user requested Goerli ETH (GETH) or Mumbai MATIC, we consecutively called getTransactionReceipt
until the transaction was confirmed as mined, often requiring many calls to getTransactionReceipt
per single user request.
With nominal faucet traffic, and without a legacy web3 library bug, this model would have been extremely silly, but not exorbitant.
We would have sent, on average, ~16 calls to getTransactionReceipt
every time a user requested tokens from the faucet.
2. Using a legacy web3 library
Our service was using a legacy web3 library that, unbeknownst to us, had a bug. Even after confirming a successful transaction, the system would continue to call our nodes, drastically increasing the total number of (unnecessary) calls to getTransactionReceipt
.
Solution: Alchemy Notify and the Alchemy SDK
The two main solutions we implemented to reduce expensive JSON-RPC calls to our nodes were:
Replaced getTransactionReceipt calls with Alchemy Notify's webhook notifications
Replaced the legacy web3 library with the Alchemy SDK
1. Migrating to Alchemy Notify
We have abandoned calling the raw getTransactionReceipt
method, and started using Alchemy Notify’s webhooks to get real-time notifications when transactions are mined and dropped. With zero outbound calls, notifications are sent directly to us when users successfully receive GETH.
2. Upgrading to the Alchemy SDK
We migrated from the legacy web3 library to the Alchemy SDK, effectively fixing the bug that exponentially increased the number of required getTransactionReceipt
calls.
Annualized Cost Savings
These two simple changes saved our team an annualized cost of over $3,000,000. To run our faucets, we reduced the total annual cost to approximately $560. 🤯
What this means for your project
Products like Alchemy Notify and the Alchemy SDK are designed to solve problems that make running your web3 products unnecessarily expensive, cumbersome and time-consuming.
They’re super easy to set up and the cost and time-saving benefits will ensure you can have the time and money to focus on your frontend core business, instead of worrying about your backend infrastructure.
Related articles
Scaling The Smurfs' Society with Gas Optimized Transactions
The Smurfs' Society used Alchemy's gas optimized transactions to guarantee mined transactions on Polygon during periods of high gas price volatility.
Dolomite leverages Alchemy for data integrity
Dolomite ensures blockchain data integrity with Alchemy, overcoming past challenges for reliable and swift data access.