First we need to determine the purpose.
- To experiment, e.g. want to test a certain configuration, load testing, troubleshooting, etc. In this case, you don’t need the instance to be online all the time.
- To host a site or web application.
Experimentation
If you need an EC2 instance for experimentation, the cheapest is to use Spot instances.
This is my typical setting for a t3.micro instance. Taken from https://aws.amazon.com/ec2/pricing/, Singapore region price is $0.0132 (which means $0.0132x 24 hours x 31 days = $9.8 per month). I set my maximum price at $0.0025, which is $0.0025 x 24 hours x 31 days = $1.9. That’s a 80% discount! Amazing!
Note that I didn’t factor in the cost of the EBS volume (i.e. hard drive).
Hosting
AWS Lightsail (https://lightsail.aws.amazon.com)
For hosting a site or web application, I find AWS Lightsail to give you the best value for your money. An On-Demand EC2 instance with 2 vCPU & 2GB RAM (e.g. t3.small, t3a.small) is priced at $0.026 per hour, which equates to around $19 per month, with a 60GB volume gp3 costing $0.096 x 60 = $6 per month, total is $19 + $6 = $25. A 2 vCPU, 2GB RAM, 60GB SSD in Lightsail is only $10 per month. That’s more than 50% discount!
You even get 3 months free for the first bundle that you run. Quite amazing really.
What are the drawbacks? You don’t get the full EC2 features, for example
- You can’t choose a smaller volume, smaller volume means you can snapshot more often.
- You can’t attach more network interfaces, so you are confined to only using 1 static IP per instance. You can still host multiple sites in a instance, but sometimes you want each site to have its own IP.
- You can access S3 buckets, but can’t attach EFS (networked shared folder).
Savings Plans
If you know you are going to host in AWS for the next year or so, you can save by using purchasing a Savings Plan. From https://aws.amazon.com/savingsplans/compute-pricing/
Reserved Instances
Another way to save money is to use Reserved Instances. However, I find these to be too restrictive (if you change your mind later). The whole point of using a cloud infrastructure is to be “elastic”, you can scale up or scale down depending on your needs. With Reserved Instances you are kind of locked into a specific instance type/class. Even AWS itself recommends using Saving Plans.