Assumption: Let's say you run an application / function with 5 qps traffic, needing 256 MB RAM max, 50ms execution time.
EC2: t2.micro instance - 1 instance available as always free, hence using as a baseline. This comes with 1 vCPU and 1GiB RAM - cost $0.0116 / hour x 750 hours a month = $8.7 / month.
Lambda: For 5 qps traffic, it would amount to 13,392,000 requests in a month. With a 256MB instance, and 50ms of execution time, that comes to $2.48 / month, after accounting for 1M free requests.
The math goes in EC2's favor once you cross 20 qps.
Thanks for the detailed reply! :) So thinking from a business development standpoint, would it just make sense to go for FaaS if one knows that the average traffic of the application will remain below this mark (20qps)?
And for an application that is intended to grow without a cap, then pick EC2 from the beginning?
Yes, FaaS is a good choice for early stage products, where the traction cannot be predicted, or the user volumes would be predictably low. Combine Lambda (execution) with other free tier + subsequent low cost serverless offerings like DynamoDB for data, you can achieve a truly cost-effective solution with FaaS. Cold-start is not that big an issue, for full functionality web-apps, every now and then, the first request seems to take maybe a second longer.
Cons: Learning + debugging curves are higher.
Source: Built a SaaS product mostly based on Lambda and it was very cost effective - as in - 1/20 the costs of the traditional EC2 route.
EC2 can be a good pick if your engineers are more comfortable with leveraging what they know and speed / a quick go-to-market is of more importance.
FaaS has been remarkably good for many companies with very late stage products running with very large numbers of users for a very long time. The speed of development even in a mature product and the much lower maintenance overhead make FaaS (or rather serverless) applications a very compelling way for teams to get solutions out fast and cheap over a long term and with very large user bases. This is after designing, building and working with dozens of teams to build serverless applications using Lambda and many other AWS services since 2016
It also depends on traffic patterns. For EC2 you're paying per hour regardless of whether you had traffic or not. For Lambda you're paying per unit of time used and you pay nothing when the function isn't invoked.
Assumption: Let's say you run an application / function with 5 qps traffic, needing 256 MB RAM max, 50ms execution time.
EC2: t2.micro instance - 1 instance available as always free, hence using as a baseline. This comes with 1 vCPU and 1GiB RAM - cost $0.0116 / hour x 750 hours a month = $8.7 / month.
Lambda: For 5 qps traffic, it would amount to 13,392,000 requests in a month. With a 256MB instance, and 50ms of execution time, that comes to $2.48 / month, after accounting for 1M free requests.
The math goes in EC2's favor once you cross 20 qps.
Can a t2.micro run such a load - oh yeah!
[1]: AWS EC2 On-demand pricing: https://aws.amazon.com/ec2/pricing/on-demand/ [2]: AWS Lambda pricing: https://dashbird.io/lambda-cost-calculator/