>_
Dating App theory part 5 - AWS
This is the fifth part in a series Im writing about a dating app I wouldnt actually build. In previous parts we established some rules for the app and a budget. Weve also been through a look at costs for a VPS setup and a setup using Cloudflare. Here we shall look at using AWS for the solution with a budget of £50 per month.
EC2 / Lightsail
Firstly lets have a look at the pricing if we just used EC2 or Lightsail. Lightsail is AWS's bundled offering, which is most likely aimed at rivaling the likes of Linode or Digital Ocean. We previously looked at Linode
here, lets see what the equivalent servers would cost with AWS:
- AWS 2GB Bundle: 2GB RAM, 1 vCPU, 60GB Storage, 3TB egress - $9.81
- AWS 4GB Bundle: 4GB RAM, 2 vCPU, 80GB Storage, 4TB egress - $19.62
So these are obviously prices to rival competitors, especially with more storage and slighty more egress for the 2GB server. An issue I always see with AWS EC2 and their other products is they dont always account for egress, so its nice to see this bundled with the Lightsail instances. They also offer a 500MB version thats just $3.43 which would look to be similar to using Fly. Or that may come into use later.
Also worth mentioning here that automatic backups can be setup for these lightsail instances at a cost of 5 cents per GB-month. These are optimised too, so only the differences between two snapshots will count towards the cost. Either way cheap backups of the instances which make this option quite attractive.
I see this offering as the equivalent of supermarkets offering cheaper products to get people in the door. Either way this could still work. Now lets look at a more intricate configuration using some of AWS's different offerings.
DynamoDB
So we could get a managed Postgres instance but these can be costly. Another option is DynamoDB. This is a NoSQL document database similar to Cloudflare KV which we looked at previously. They offer a very generous free tier which is always free. These are calculated slightly differently with Capacity Units. This boasts enough to handle upto 200M requests per month and 25GB free storage. So this is more than enough for us and is the best option in this case.
Cloudfront / S3
For images and serving those images, we have S3 and Cloudfront. S3 is AWS's storage option and Cloudfront is their CDN. Lets look at our costs for our images:
- Storage: 0.25GB: $0.10
- Outbound Data Transfer to Cloudfront: Free
- Cloudfront: 300GB - $6.00
Total: $6.10
I got a bit lost here. As far as I can see, going straight from S3 to the Internet is expensive but then transfer to Cloudfront is free. The first terabyte from Cloudfront to the internet is free, which is fine for us. But then Data to our origin will cost $6 for our 300GB. Im confused by all of this, as mentioned before it can be the egress that costs alot with AWS. This is most likely why Cloudfront charges nothing for it.
Also its worth mentioning here that the static site can be served through S3 / Cloudfront, and as far as I can see Ive included this in the Cloudfront bandwidth, so I would class this as free.
Compute
With compute we have the choice of lambdas, similar to Cloudfront Workers. Or we could just use small servers. Lets get a breakdown of each. With Lambda, its just silly cheap to be honest. The more memory you allocate to Lambdas, the more CPU you also get, so its worth increasing the memory for CPU intensive operations. In our case we would most likely just be calling DynamoDB and serialising data:
- Lambda: 5 million requests per month, 300ms per request, 512MB memory - $13.50
I havent done any maths on how many requests we would actually make. Just more an idea of how long requests would take. I think this would more than cover our needs and so our cost would be less.
Going back to the Lightsail instances, heres the smallest server available:
- AWS Bundle 0.5GB: 500MB Memory, 1 vCPU, 20GB Storage, 1TB egress - $3.43
This would just be used for the cron tasks we use, so it would mainly be making requests to DynamoDB to get and change data.
Total: $16.93
Overall with compute, I think this is a really good price as we wouldnt actually pay this much, its a maximum which is something I didnt do with the other on-demand services we've looked at previously. I think this is a good option for handling heavy load too, as the Lambdas can be called at the same time and DynamoDB has no issues with concurrent calls. Especially with our workload where it would be users requesting and altering completely different data.
There is a free tier with Lambda too which would decrease the price, but I think this is a limited offer so didnt include it in my calculations.
Conclusion
Our totals for the more intricate setup are as follows, mapped in a similar way to the Cloudflare totals:
- Lambda: $13.50
- DynamoDB: Free
- S3/Cloudfront: $6.10
- Cron: $3.43
- Static: Free
Total: $23.03
As mentioned before, the lambda price is a maximum so this overall price would most likely be lower by around $5. But equally Im not sure if I calculated the S3/Cloudfront prices very well so it may balance out.
Honestly I thought before looking into AWS that Id have to mention in the conclusion that I wasnt doing this post to just dunk on AWS, as I thought the pricing would be ridiculous. But this is quite competitive in my opinion. Although theres some setup complexity for the Lambdas, I think they offer better performance than just using a normal server. Egress fees still seem to be an issue with AWS which was a concern I still feel no better about after investigation.
I am of the opinion that AWS has a place and that place is mainly for enterprise. I still sort of think that in this case, because although these calculations are good, I think if this was to scale (I know, eye roll) then AWS would be the most costly. But like I say I think that this price offers some really good performance over just using a single server. There is also the option of just using the Lightsail instances we first looked at, which I think may offer a better price that VPS rivals.
In the final part of this series, we shall round up the findings and explain why this probably isn't an app actually worth building.
19 Dec 2022, 12:18 p.m.
Home