Should You run your own Ethereum node?
TLDR: In most cases, you should not host your Ethereum node, but it depends.
Recently, I had the opportunity to refactor a somewhat big Dapp in the Ethereum network and I got my hands dirty into the matter of going through the trouble of keeping hosting your node or just going with the KISS architecture (Keep it Simple, Stupid) and just use a trusted party service.
Table of Contents
- Why do you need a Ethereum node?
- Advantages of hosting your Ethereum node
- Advantages of using a trusted party Ethereum service
- Price comparison
1. Why do you need a Ethereum node?
If you are a dapp developer you probably need some off-chain infrastructure, to either run cronjob tasks or to automatically manage private keys, etc.
The single best way to programmatically interact with the Ethereum network is by using the API that Geth gives you, which allows you to separate your off-chain logic from the logic that signs transactions and the way networks sync and communicate.
2. Advantages of hosting your Ethereum node
Hosting your node, give you more:
- Privacy: you are not sharing access to a trusted party node.
- Availability: no matter how trustable a 3º party can be, there will always be some downtimes, even if it is only some seconds or minutes, you have to bake some retry logic into your code to handle that.
- Flexibility: you can host private keys inside your Geth node (which is not recommended!) and skip right away all the signing transactions.
These are 3 top advantages from my point of view, but there are surely others that you will find out if you decide to go this way.
3. Advantages of using a trusted party Ethereum service
The first thing to consider here is to decide which provider you should pick, there are a ton of them and as time goes on more are going to appear.
The top providers I can think of are Infura, Alchemy, and more recently Etherscan.
I picked Etherscan for the project I worked on, because of the additional endpoints they have besides the usual Geth ones, and secondly, I was already using their website to track the project wallets and contracts, so it made a lot of sense to just use their API as well.
Some of the advantages of using a trusted party service are:
- Mindfulness: you don’t have to worry about upgrading your node and always keep looking into the patch notes of each version.
- Sleep time: every time the node goes down, it’s not your job to go troubleshoot the problem and fix it ASAP, and because these trusted parties already have a ton of experience running the nodes, they probably are not even gonna sweat when it happens.
- Cost optimization: for most of the applications, you are not going to make a lot of transactions per minute, and that allows you to run almost indefinitely on their free tier (more details below).
- 2º layers: when it’s time for you to move to a second layer or even another network like Binance Smart Chain, all you have to do is change the base API endpoint, because the interface is almost the same between the Ethereum like chain’s
One of the main disadvantages to using a trusted party is that you will be missing the feature to let Geth manage your private keys and transaction signing, so you need to consider that while developing your integration with the blockchain.
4. Price comparison
The chapter you have been waiting for, a cost comparison between self-host and trusted party.
Just to give a little more context, our eth contract had well-defined events that made it much easier crawling the network.
All I had to do was call the eth_getLogs
endpoint with our contract address and it returned a maximum of 1000 events
for as many blocks as I wanted.
I made some calculations and in the most extreme case, we could only crawl 25 blocks per call, which would give us about 40 events per block, which is more than enough for our usage.
Our cost of running our node in AWS was the following:
- The current network size is about 1TB, which equals to about 300$ per month in EFS that is attached to our running instance
- We were running a pretty overkill instance for a Geth node, that cost us about 200$ per month (because we were also running some service side-by-side with the Geth there)
- I didn’t make the calculations for egress traffic to the instance
After the migration to Etherscan API, which completely removed the EFS storage and downgraded the instance to 1/4, ended up saving about 450$ per month in the AWS bill.
In the new Etherscan API we were able to just keep using the free tier indefinitely because we had such optimized requests.
In short, every case is different. But starting out with using a trusted party for the first steps of any project is always advantageous, and later you can reconsider upgrading to a self-hosted node.