I've been using AWS for a simple webapp for some time. I've noticed the costs are way too high for the app's usage:
EC2 t2.micro
: $28/moLoadBalancer-hour (or partial hour)
: $37RDS db.m1.small instance hour (or partial hour) running MySQL
: $50
$100+/mo all for a site that has 5-10 users a day.
How can I scale down my existing EC2 and RDS instances and remove or reduce load balancing needs without redoing the work of setting all of that up?
Basically, I need to accomplish these things:
- Serve my frontend static app (in S3 currently) over HTTPS (currently using Cloudfront to do so)
- Serve my backend API (in ElasticBeanstalk currently) over HTTPS (I was told I need load balancing for this)
- Host a database (currently using AWS RDS with ElasticBeanstalk)
- There aren't many users currently, so I need much cheaper API hosting than $80+ a month for RDS and EC2. Need these services to be more around $30 total/mo. I don't see the need at all for load balancing, but like I mentioned, I thought I needed this for https?
Best Answer
You don't need ELB or RDS. Note that ELB provides some security, protecting against some layer 4 and 7 attacks. You might choose to use CloudFlare (free) or CloudFront (cheap) to replace ELB, or you could go without. It's cheap security, and it offloads work from your server.
I run Nginx, PHP 5.6, and MySQL on a t2.nano. In the past 24 hours I've had 1500 users and 15,000 requests to around 15 websites. Some static resources were cached by the CDN, but all pages hit the server. The server uses about 2% of CPU according to CloudWatch, the average rarely climbs higher than that over a 5 minute period.
I have a tutorial on how I set this all up.
Key things I did are:
Migration
The best way to migrate MySQL is to use mysqldump. Set up MySQL on your server and configure it for low RAM, add a page file, dump the database from RDS into a file on your server, then upload the database to your serve. You'll probably need to set users and permissions up again. Do a final manual snapshot of your RDS database, then turn RDS off. In a few months go back and delete your RDS snapshot if all is well.
To change the size of your EC2 instance stop it, right click and change instance size, then start it again. It takes a minute or two. You can do it via the API if you want to.
Answers to Questions
HTTPS: "it seems like in order to have https with AWS, I need load balancers for my EC2 instances"
There are many ways to add https to EC2 servers.
Note that if you have your domain configure to route traffic to an ELB you'll need to change things a bit. The easiest way is likely to be getting an elastic IP address for your EC2 instance and putting that elastic IP into your DNS configuration, as an A record.
Instance Size: I can't give you a concrete answer here as we don't have enough information. Changing from t2.micro to t2.nano should be easy since they're the same technology, just smaller.
If you were moving from another instance type I'd say check your AMI, maybe it's an old PV AMI rather than a newer HVM AMI. If you edit your question to give more information I can have another think about it.