How to migrate a Wordpress website from Lightsail to EC2
A while ago I created a website page to have a place where I could publish related stuff to bonsai world, this is tiendabonsai.net. I wanted something ship and easy to maintain so I ended up looking at AWS LightSail.
I chose the cheapest configuration that was $3.5 a month with the first month for free. That included 512MB, 1 vCPU, 20GB SSD of storage and 1TB of transfer bandwidth.
When I started creating posts with images and creating static pages all was fine, it wasn’t super fast but was enough to keep creating content.
After a while I started facing some problems when uploading images, somehow the server was getting stuck and not responding for around 30 minutes. Sometimes I even needed to manually restart them. All this was causing some downtimes that I didn’t really wanted for a project that just started and needed to be fully running to not affect SEO of the site.
After analyzing the few metrics that AWS LightSail gives I saw that the problem was mainly on CPU usage. When I had an spike of CPU the instance wasn’t able to recover fast.
Thinking on increasing to a higher instance
First, I thought on increasing the instance type to a one that increases the vCPUs. The option was getting 2 vCPUs with the $20 plan, the fourth one. Also, included 4GB of memory, 80GB SSD storage and 4TB transfer.
The problem is that AWS was forcing me to get things that I didn’t really needed in the price increased a lot, from $3.5 to $20.
The good point is that upgrading was as easy as creating a snapshot and run a new instance from this snapshot.
For that price I thought on checking a simple AWS EC2 instance. After checking several instance types I ended up with t3a.micro that includes 2 vCPUs and 1GiB of memory for just $0.0094 per hour, so $6.9 per month. This was clearly a super good solution even though here we should add the costs of the EBS volume.
The volume I had before was of 20GB so I chose the same on EBS as general purpose SSD (gp2) which costs $0.119 per GB-month, which ends up being so far 3GB so $0.38.
Migration from Lightsail to EC2 step by step
Here the step by step migration process I followed:
- I went to Lightsail console
- I created a snapshot of the current instance. More info here.
- In the snapshots tab there is a drop-down menu where you can choose Export to Amazon EC2.
- Then I went to AWS EC2 console, then in AMIs pane.
- I selected the AMI that got created from the Lightsail snapshot and I clicked to Launch.
- Then I created a new key pair and I downloaded it to my computer.
- Then I chose Launch instances.
- When it was running I entered via SSH to the instance and I removed the old LightSailDefaultKeyPair in
- I went to Route53 and I changed my hosted zone to start pointing to the new EC2 private IP.