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
🌐
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...?

🌐
Lumigo
lumigo.io › guides › aws lambda 101 › aws lambda cost factors, cost comparisons and optimization [2024]
AWS Lambda Cost Factors, Cost Comparisons and Optimization [2024]
August 30, 2024 - If you’re not reliant upon a ... your code functional – simply deploy the code and go! AWS Lambda gives you far more granular ways to measure your costs than EC2, which bills based on time instead of based on resource ...
🌐
CloudZero
cloudzero.com › home › blog › ecs vs. ec2 vs. s3 vs. lambda: the ultimate aws comparison
ECS Vs. EC2 Vs. S3 Vs. Lambda: The Ultimate AWS Comparison
August 29, 2025 - The downside is that Lambda instances automatically scale beyond set limits, so something like this can quickly increase your AWS bill. Without a cloud cost intelligence platform to detect and alert you to such cost anomalies, you would quickly go over your AWS budget for the month. EC2 allows you to implement security best practices at the instance level.
🌐
Trek10
trek10.com › homepage › blog listing › aws lambda pricing in context - a comparison to ec2
AWS Lambda vs EC2 Cost Comparison - Trek10 | Trek10
One approach here is to look at ... 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....
Price   $
Address   1400 E. Angela Blvd, Suite 209, 46617, South Bend
🌐
PureLogics
purelogics.com › aws-lambda-vs-aws-ec2
AWS Lambda vs AWS EC2: What’s Best for Your Use Case?
December 23, 2024 - In contrast, Lambda charges are based solely on compute time used and the number of requests processed. You only pay for the actual execution time of your code—there’s no cost when the code isn’t running.
Top answer
1 of 3
11

Based on the discussion in the comments I'm now adding a complete answer to this, as this is not really suitable for a comment.

You mentioned that your current service is already running on EC2 and you'd like to move that over to a Serverless solution. Furthermore you mention the options of "Lambda or Serverless exposed via API-Gateway". Then you add some additional information about expecting a response time of 500ms and the Lambda doing 2 DynamoDB calls.

I'll address these points in order:

EC2 vs Serverless Solution:

You seem to have already decided on trying the Serverless route, which works quite well in principle for a Microservice-Type architecture you're describing. I'm not going to focus too much on the merits of the EC2 solution here. Going serverless can have the following benefits (among others):

  • Cost effectiveness: You pay only for the resources your code consumes while it's running and not for idle times
  • Scalability: Lambda scales horizontally, fast and effortlessly - you basically don't worry about it (up to 1000 parallel "instances")
  • Lower operational overhead: No need to patch operating systems - AWS takes care of that for you
  • Focus on your business logic, leave the heavy lifting of managing the infrastructure to AWS

Lambda or Serverless exposed via API-Gateway

Serverless isn't really an AWS Service but a paradigm or architectural pattern so these options don't completely make sense - you'd use the API Gateway to trigger Lambda functions whenever an Event (read: HTTP-Request) occurs. This means you'll setup a fully-managed REST-Endpoint (API-Gateway) to call your code (Lambda) on demand.

On Performance

A response time of 500ms is realistic for the use case you're describing - DynamoDB advertises single-digit-millisecond latency, so two calls to it within 500ms shouldn't be a problem. Unfortunately Lambda cold-start is a thing. Lambda scales out with parallel requests, meaning a new Micro-VM gets provisioned if there aren't enough warm instances of your function available to serve your request. This takes time, but in your use-case this shouldn't be an issue, since you don't need access to a VPC (in that case it would take multiple seconds).

Lambda is limited in performance compared to EC2 instances, you scale the amount of performance Lambda provides by specifying the amount of RAM the function gets allocated (CPU resources are provided based on the RAM). For a simple Login-Service this shouldn't be an issue as well.

I suggest you read up on the points I mentioned in the Lambda documentation (which is quite good).

2 of 3
0

If you want your events driven service managed use AWS Lambda, you just provide the code in the required language, and Amazon AWS does the rest. If you want to customise for your own needs and use whatever coding language you prefer Amazon EC2 offers flexibility and a whole range of EC2 Instance types to choose from, in conjunction with Elastic Beanstalk services for deploying onto Amazon EC2.

AWS Lambda is a service for running code in response to events, such as changes to data in an Amazon S3 bucket and Amazon DynamoDB tables, or as compute services to run your code in response to HTTP requests using Amazon API gateway or API calls made by using AWS SDKs. This is an ideal computing platform for applications when running within the standard runtime environment.

Lambda should be your best bet.

🌐
CloudySave
cloudysave.com › aws › ec2 › aws-lambda-pricing-vs-ec2
AWS Lambda Pricing Vs. EC2 - CloudySave
March 31, 2021 - Lambda Function Cost= $0.16. Also, having similar requirements, we may choose the EC2 Instance of “t2.nano”.
Find elsewhere
🌐
Medium
medium.com › life-at-apollo-division › compare-the-cost-of-aws-lambda-fargate-and-ec2-for-your-workloads-ad112c4740fb
Compare The Cost of AWS Lambda, Fargate, and EC2 For Your Workloads | by Milan Gatyás | Life at Apollo Division | Medium
November 28, 2022 - The following graph shows the monthly price of each service based on a percentage of time utilization. EC2 pricing is indeed the lowest one, followed somewhat closely by Fargate, while Lambda pricing is about double of Fargate.
🌐
Lumigo
lumigo.io › home › aws lambda vs ec2: compared on performance, cost, security, and more
AWS Lambda vs EC2: Compared on Performance, Cost, Security, and More - Lumigo
June 25, 2024 - Related content: Read our guide to AWS Lambda cost · Let’s assume an application has 5,000 hits per day with each execution taking 100 ms with 512MB. So the cost for the Lambda function will be $0.16. To get the same hardware resources, you ...
🌐
Businesscompassllc
businesscompassllc.com › home
AWS Lambda vs. EC2: Decoding the Cost Battle for Optimal Cloud Hosting - Business Compass LLC®
August 22, 2024 - Lambda inherently handles load balancing within its architecture, automatically scaling up to handle incoming requests. EC2, however, requires the additional setup of an Elastic Load Balancer (ELB), which adds to the overall cost and complexity. AWS Lambda is ideal for lightweight, unpredictable workloads, microservices, or when you need to minimize overhead and maximize agility.
🌐
Dzhuneyt's Blog
dzhuneyt.com › post › aws-lambda-vs-aws-ec2-cost
AWS Lambda vs AWS EC2 - Cost Comparison - Dzhuneyt
November 13, 2024 - You probably noticed that all three of the EC2 instances have a linear pricing growth, because their hourly price is fixed and not bound to the number of requests. The red line is the Lambda costs.
🌐
Quora
quora.com › Which-is-more-cost-efficient-in-AWS-for-Web-Applications-EC2-Instances-or-Lambda-and-other-services
Which is more cost efficient in AWS for Web Applications, EC2 Instances or Lambda and other services? - Quora
Answer (1 of 30): This usually depends on your execution times and how much memory your process consumes per invocation. If you have a large memory footprint and a long-running process, you are usually better off using EC2-based services, including AWS Batch. Always compare your options when pic...
🌐
TechTarget
techtarget.com › searchcloudcomputing › tip › An-overview-of-Amazon-EC2-vs-AWS-Lambda
An overview of Amazon EC2 vs. AWS Lambda | TechTarget
Unlike EC2, Lambda charges only for active compute time and the number of requests made. The cost of Lambda compute time represents measurable work from the service -- execution to termination.
🌐
LambdaTest Community
community.lambdatest.com › general discussions
Why is Lambda considered more expensive than EC2 for serverless computing? - LambdaTest Community
June 2, 2025 - I’ve been comparing Lambda and EC2 pricing, and I’m struggling to understand why people claim Lambda is more expensive. For example, a 128MB Lambda costs $0.00756/hour, while a t4g.nano EC2 instance (with 0.5GB RAM) cost…
🌐
Dashbird
dashbird.io › home › aws lambda vs ec2: a comparative guide
AWS Lambda / EC2: Which Is Best? | Dashbird
July 25, 2023 - AWS SAM: A model to define serverless applications. With Lambdas, you pay only for the compute time you consume – there is no charge when your code is not running. Use our Lambda cost calculator to estimate your costs.
🌐
Medium
aws.plainenglish.io › serverless-vs-ec2-optimising-efficiency-in-the-cloud-a32b92d4ea66
Serverless vs EC2: Optimising Efficiency in the Cloud | by Chris Chin | AWS in Plain English
October 21, 2024 - When building and scaling cloud applications, two key options typically come into consideration — serverless functions like AWS Lambda and traditional EC2 instances. While both have their strengths, understanding how each of them optimises for efficiency is key to making the right architectural choice. ... About this Serverless vs EC2 series, the previous blog, Serverless vs EC2: Which One Fits Your Needs? has talked about the cost.
🌐
Substack
urielbitton.substack.com › p › lambda-vs-ec2-which-compute-service
Lambda Vs EC2: Which Compute Service Is Cheaper?
December 16, 2024 - Lambda is ideal for event-driven workloads with ephemeral invocations, often being much cheaper than EC2. However, for consistent, long-running processes with higher traffic, EC2 becomes the more economical choice, emphasizing the importance ...
🌐
Amazon Web Services
aws.amazon.com › compute › aws lambda › pricing
AWS Lambda Pricing
2 days ago - Total charges Total charges = Compute charges + Request charges + Provisioned Mode for ESM charges Total charges = $1,000 + $60 + $133.2 = $1,193.2 per month for 10 ESMs Monthly costs per ESM = $1,193.2 / 10 = $119.3 per month per ESM · Data Transfer Data transferred “in” to and “out” of your AWS Lambda functions, from outside the region the function executed, will be charged at the Amazon EC2 data transfer rates as listed under "Data transfer".
🌐
Serverless Team
serverless.direct › post › aws-lambda-vs-ec2-which-one-to-choose-for-your-app
AWS Lambda vs. EC2: Which One to Choose for Your App
September 25, 2023 - AWS Lambda is cost-effective for event-driven workloads with sporadic or variable traffic. You benefit from "pay-as-you-go" pricing and automatic scaling, eliminating the need for over-provisioning.
🌐
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.