Migrating sitemonki from AWS to Linode

So I have been running sitemonki.com on AWS for over two years now. AWS is a great public cloud service provider which powers a big chunk of today’s internet. While AWS has all the computing resources you will need to run today’s internet service, its pricing is not exactly the most pocket friendly. I have received bills from AWS I can’t really explain even to myself. Sitemonki is still on freemium right now, so cost is really a priority to me.

I have also been concurrently using Linode to run some websites I manage for clients. Linode is not only super straightforward in terms of provisioning cloud infrastructure, but also has dead simple pricing. For my current needs, Linode’s infrastructure is more than capable of handling whatever I throw at it. So I made the decision to migrate Sitemonki from AWS to Linode.

AWS S3

Alright, before I talk about the migration itself, here’s a list of services I have been using on AWS; S3: To be honest, AWS’s S3 is my favorite product from Amazon. It’s no wonder that S3 is the same service that catapulted it to be the cloud infrastructure juggernaut it is today. To put it simply, S3 is like the internet’s hard drive. You can store all sorts of data on S3 for short and long-term storage. Even more, you can share this data with anyone online with a simple URL. S3 has a number of tools and APIs that makes it accessible from a number of platforms including your App, website or server. I have been using S3cmd tool to backup databases to S3.

The problem I encountered was pricing. S3 pricing used to be straight forward as far as I remembered. You pay a certain amount for storage/month along with data transfer in and out. Using Amazon’s own example, assume you store 100 GB (107,374,182,400 bytes) of data in Amazon S3 Standard in your bucket for 15 days in March, At the end of March, you would have the following usage in Byte-Hours: Total Byte-Hour usage = 107,374,182,400 bytes x 15 days x (24 hours / day) = 107,374,182,400 x 15 x 24 Byte-Hours. For the month of March which as 31 days or 774 Hours, then GB-Months = 107,374,182,400 x 15 x 24 Byte-Hours/1,073,741,824 bytes per GB / 744 hours per month. This gives us 48.387GB-Months which should give us 48.387GB-Months x $0.023 = $1.113/month. However, I was getting a bill of about $43/month. I might have some data I am not aware of. So I am going to investigate further with less than 10GB of data and check on my monthly bill. For now I’ll be switching to Linode’s Object storage.

EC2

Another service I was using was EC2. These essentially are virtual private servers from Amazon billed per hour. You can either go with shared instances or dedicated ones. I was using shared ones. I have been using a t2.medium which offers 4GB of RAM and two virtual CPUs. It has been working just fine, but at $41/month. With Linode, you pay half of that. It’s just $20/month.

Migrating sitemonki app to Linode

Once the decision was made, the migration itself was a lot smoother than I had anticipated thanks to Docker. Practically the only downtime I had was due to unavoidable DNS propagation delays.

Sitemonki app runs on a number of docker containers. All I did was commit my docker containers into new images. I then pushed these immutable images to docker hub and backed up the Mysql databases. Once the new Linode server was provisioned, I installed Docker and Docker compose on Ubuntu 20.04 LTS instance. I then pulled my Docker images from a private free docker registry and run my containers off them. Practically that meant, re-using all dependencies already installed in the docker image without having to re-install them afresh from their respective repositories. Docker’s free package allows you to have only one repository which is fine with me.

Once the docker images where pulled from Docker Hub, I then restored the database dumps to the newly created Docker containers. I thought of moving my container volumes, but I realized this was unnecessary. Backing Mysql database and restoring it was much faster and easier.

Once Docker containers were running smoothly, all I had to do now was install Nginx and configure it as a reverse proxy. That also meant installing Letsencrypt’s certificate provisioning tool. I just reused the same server configurations from the previous server.

In no time, migration was successfully done with minimal downtime and headache on my part.

What I learnt.

  • Docker is an incredible tool for deploying and running web apps on the cloud. It has a fairly long learning curve, but totally worth it. Docker guarantees that your App runs the same regardless of the server environment the app is deployed.
  • You can use Docker Hub to store your application images. It’s like taking a snapshot of the environment your application was running on smoothly and then saving it somewhere. We know that web development changes like crazy. Sadly I don’t have time to keep up with the latest changes in frameworks, packages, dependencies etc. For instance, sitemonki’s web interface still runs on Django 2.1 whereas the latest version is 4.0 as of 2022. The backend runs on Golang 1.12 while the latest version is 1.17. If I was to run sitemonki today with latest packages, alot would break and patching the app would take a very long time with alot of downtime I can’t afford.
  • Your app doesn’t need to run the latest tech stack. I don’t intend to patch Sitemonki’s stack anytime soon even when I get some free time.
  • Linode is an extremely simple cloud provider with more affordable pricing suited for small web shops like me. AWS on the other hand is a heavyweight hammer ready to take on more serious workloads for those with an equally serious budget.

Leave a Reply

Your email address will not be published. Required fields are marked *