Besides what others commented about concurrent reqs in EC2 vs independent lambda execution costs, the trick considering all that is that Lambda is more efficient in terms of costs than EC2 UP UNTIL a certain amount of reqs/s, from that threshold onwards, the appropriate EC2 instance is cheaper. Engineers at BBVA came to this conclusion and wrote the whole analysis they made: https://www.bbva.com/en/innovation/economics-of-serverless/ Answer from HarrityRandall on reddit.com
Trek10
trek10.com › homepage › blog listing › aws lambda pricing in context - a comparison to ec2
AWS Lambda vs EC2 Cost Comparison - Trek10 | Trek10
How much compute would your EC2 instance have to do to be cheaper than Lambda for that same workload? For comparison, we’ll use a typical workhorse instance, the m4.large instance type. It has 2 vCPU and 8 GB RAM and costs $0.12/hr or approx $86/month in the N.
Reddit
reddit.com › r/aws › why is everyone saying lambda is more expensive than ec2?
r/aws on Reddit: Why is everyone saying Lambda is more expensive than EC2?
May 23, 2023 -
Please help me work out the math here, as I think I am doing this wrong.
A Lambda of 128mb costs $0.0000000021/ms, this works out $0.00756/hour. A Lambda of 512mb costs $0.0000000083/ms, this works out $0.02988/hour.
Now if you look at EC2:
t4g.nano $0.0042/hour (0.5 GiB ram) t4g.micro $0.0084/hour (1GiB ram).
But... the Lambda will likely not run 100% of the time, and will stay warm for 10 minutes (not sure here?). And the RAM usage would be much better utilized if you got a function running, rather than an entire VPC.
Given all that, if the function can run with 128mb or less, it seems like a no-brainer to use Lambda.
However, if the function is bigger, it would only make sense to put it in an EC2 if it runs more than 30% of the time ($0.0084/hour cost of t4g.micro divided by 0.02988/h cost of 512mb lambda).
So why is everyone against Lambdas citing costs as the primary reason...?
Top answer 1 of 39
124
For EC2 you can run more than 1 request at the same time. For lambda it is 1 lambda per request. If you have even a few concurrent requests you lambda cost can 5-10x noting all the cold start and other times too.
2 of 39
100
If you expect to not have traffic 24x7 and low concurrent usage then Lambda may end up working out to be cheaper. Lambda is extremely expensive for my company because we have hundreds or thousands of concurrent executions.
Videos
02:32
Lambda or EC2? - YouTube
16:25
AWS Lambda vs EC2: What to choose for your company and why? - YouTube
19:52
AWS EC2 vs Lambda | Whats the difference? Pros and Cons? - YouTube
AWS Lambda Vs EC2 | Serverless Vs EC2 | EC2 Alternatives
16:50
AWS EC2 vs ECS vs Lambda | Which is right for YOU? - YouTube
Lambda Pricing Explained in 5 minutes - YouTube
Amazon Web Services
aws.amazon.com › compute › aws lambda › pricing
AWS Lambda Pricing
2 days ago - You configure your Lambda Managed ... Monthly request charges: 100M / 1M × $0.20 = $20 · Compute charges Instance type: m7g.xlarge EC2 on-demand price: $0.1632 per hour (US East N....
AWS
calculator.aws
AWS Pricing Calculator
AWS Pricing Calculator lets you explore AWS services, and create an estimate for the cost of your use cases on AWS.
Cloudphilos
cloudphilos.io › post › how-much-more-expensive-is-aws-lambda
How Much More Expensive Is AWS Lambda? A Cost Comparison with EC2
When a Lambda function is invoked by API Gateway, it serves 1 request per function invocation. 1000 requests per second will invoke the function 1000 times every second. ... If the average function execution time is 4ms processing and 200 ms waiting, you’re being billed for the full 204 ms. 1000 times per second. This means total costs rise linearly as execution time increases. ... With EC2, it doesn’t.
Stack Overflow
stackoverflow.com › questions › 56274163 › aws-ec2-vs-serverless-cost-comparison
amazon web services - AWS EC2 vs Serverless Cost Comparison - Stack Overflow
This is different to ec2 as ec2 pricing is based on hours ran. So it could be a big savings to go with serverless, but that all depends on the workload you are doing. Especially if you have times where you have low or no use as lambda and ...
AWS re:Post
repost.aws › questions › QUnZW1en-xSH2F1-B_Y7toaQ › lambda-pricing-for-starting-and-stopping-ec2-instances
Lambda pricing for Starting and Stopping Ec2 instances | AWS re:Post
April 17, 2023 - https://calculator.aws/#/addService ,2. https://s3.amazonaws.com/lambda-tools/pricing-calculator.html ... Here is the cost estimation for Instance Scheduler.
Dzhuneyt's Blog
dzhuneyt.com › post › aws-lambda-vs-aws-ec2-cost
AWS Lambda vs AWS EC2 - Cost Comparison - Dzhuneyt
November 13, 2024 - BBVA (the second largest bank in Spain) has conducted a benchmark comparing both AWS services - AWS EC2 and AWS Lambda. The most interesting chart in my opinion is the following: It compares how are Lambda's costs increasing over the days of the month (the red line), compared to running an EC2 instance of various sizes (the other colored lines).