Running a total Bitcoin knot on AWS
Running a total Bitcoin knot on AWS
UPDATE – 10th August 2014: The results are in
The knot stayed stable via July and the free tier benefits ran out before that so the following is the accomplish cost.
The main contributions to this were (incl. VAT @ 20%):
| Data Transfer | | | |:————–|—|—| | $0.120 per GB – up to ten TB / month data transfer out | 135.096 GB | $Nineteen.46 |
| EC2 | | | |:—-|—|—| | $0.020 per On Request Linux t1.micro Example Hour | seven hundred forty four Hrs | $17.86 | | $0.05 per one million I/O requests – US East (Northern Virginia) | 23,715,799 IOs | $1.43 | | $0.05 per GB-month of Magnetic provisioned storage – US East (Northern Virginia) | 48.000 GB-Mo | $Two.88 |
I just want to know how much it will cost to run a utter bitcoin knot on an EC2 example. The two main factors being disk usage (the size of the block chain at the time of writing being around 17GB) and IO (how much traffic I may have to pay for to permit incoming connections on port 8333).
- I embark with a t1.micro example running Ubuntu 14.04 (LTS) sixty four bit.
- For now I accept the default 8GB root volume and add an extra 40GB EBS volume on which I’ll store the blockchain (Originally I began with 20GB but this did not last long before running out of space and crashing the knot – i’m sure less would suffice for a while but i don’t want to resize the disk again every few days/weeks)
- I configure any IP access on port twenty two for SSH (I have to be able to configure my server – albeit I could restrict the IP addresses permitted to connect on this port for added security)
- I configure any IP access on port eight thousand three hundred thirty three (I want this to be a useful knot and not a leech! So other knots have to be able to connect)
- I create a fresh key pair to access the server using SSH and launch the example!
Next I have to connect and install/configure bitcoind. To simplify things I’ll add a
/.ssh/config file to point to my fresh key and awkward public DNS name
This permits me to connect with a elementary ssh bitcoin-node
So, now to install bitcoind …
And configure it as a service…
Before I commence the bitcoind service I want to configure it to use my EBS volume for the blockchain. The very first step of which is to initialize and climb on the volume. Run the following directive to get the device name
As you can see, in my case I have an unitialized volume at /dev/xvdb ( lsblk strips the /dev/ from the device name). So I use the following directive to initialize an ext4 filesystem
Next, I need to configure this to be mounted on boot. Very first I will create a climb on point
Then we can add the following line to /etc/fstab to climb on the volume on boot in future
Run the following to climb on the volumes listed in /etc/fstab
Now add a bitcoin system user, setting its home directory on the EBS volume
To configure bitcoind we now need to add a config file to /data/bitcoin/.bitcoin/bitcoin.conf
Now set the permissions on it
Now we can add an upstart config at /etc/init/bitcoind.conf
Before we can begin the service we need to make sure that the machine does not run out of memory and crash it. This will happen after a fairly brief time. The solution is to add a swapfile.
This creates a 1.5GB (a little over twice the RAM of 0.613GB on a t1.micro example) exchange file and activates it. In order to ensure it is activated on reboot we need to add another entry to /etc/fstab
To ensure that the swapfile is only used when it’s indeed needed we should set the swappiness. This is an optimization of the kernel. A high value (maximum of 100) would tell the kernel to favour the exchange file, we will set a low value of ten to favour RAM when it is available.
These directions set the current swappiness value and set the kernel configuration to the same value on reboot. To finish configuring the swapfile, set its permissions so that it cannot be read by other users.
Only now should we register the service and embark it…
And there we go, the bitcoin knot should be running and downloading the blockchain. I have no intention of actually using it as a wallet but hopefully it will be providing the useful services of a participating total knot. Now let’s see how the costs stack up.