It was nice to get free services from AWS under the free tier plan. It’s hard to believe a year has passed and now I have to start paying for it.
This blog will be about my first real bill and how I am going to move some services around to see if I can reduce it.
The bill is not that high. However some of the services I am using are just not cost effective considering the little traffic I get. Most of my projects are only in their MVP stage and have yet to be monetized. I want to keep them up and running and will be adding more so it is important to the keep costs down.
My July bill is $31.25 after adding $4.06 of left over credits from my AWS sponsored dynamoDB training. I am still surprised it is as high as it is.
Diving in to figure out where the costs are
I use many services at AWS: S3, SES, EC2, Lamda, Cognito, API gateway, ELB, dynamoDB, Aurora etc. The current bill below shows my major cost is for compute power using EC2 and ELB. The elastic load balancer is costing me $16.19 per month. That is twice as much as the EC2 I am running! Not a great deal.
I only used an ELB so that I could get a HTTPS connection on EC2. I really wish AWS could provide HTTPS connections right out of the box. I discovered I need HTTPS on the back end when I was developing myAgileStory.com. The front end used HTTPS and the backend, on EC2, used HTTP. I discovered that modern browsers, like chrome, would block this mixed content for security reasons.
I would like to reduce my cost by getting rid of the elastic load balancer. It was a wasted expense anyway since I only was running one EC2, but it was the only way to get HTTPS.
The other costs are with my databases. I use dynamoDB for iWantToDine.com and myDynamoDB.com and I found out that write costs are much higher at $4.15 than read costs at $0.83. You don’t want to use this technology if you write a lot to a database. It is really optimized for reading.
Switching from ELB to Cloud Front
I assumed I could use cloud front instead of an ELB and read several tutorials to suggesting that. Unfortunately they only showed examples for S3 and ELB.
As an experiment I set the “origin domain name” in cloud front to my EC2 endpoint.
One problem I ran into was it would not send the header information for my JWT authorization token. So I would get authorization errors. If I can get the headers to work I think I can get it to work. Sometimes AWS is so frustrating!
Back to Heroku
I need to get my endpoint back up running with HTTPS so I decided to redeploy it on Heroku instead. Fortunately all Heroku endpoints give you a HTTPS connection. Something Amazon still doesn’t do. The free plan with Heroku gives you 550-1,000 dyno hours per month. The hobby tier is $7 per dyno per month which is very similar to EC2 t2.micro at $8.
One disadvantage to the free plan is that the dynos spin down when not in use. This spin up time is noticeable and could lead to a poor customer experience. I am OK with this until I get more traffic.
I will not give up on getting a HTTPS connection on EC2. I will continue playing with cloud front and explore ways to do it on the server side. I tried this in the past and failed using ngnix and a free ssl certificate. It is still a challenge I would like to tackle though. If I do succeed I certainly will write a blog post about how I did it.