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
For most periodic or very light workloads, Lambda is dramatically less expensive than even the smallest EC2 instances. Focus on the memory and execution time that a typical transaction in your app will need to relate a given instance size to ...
Price   $
Address   1400 E. Angela Blvd, Suite 209, 46617, South Bend
🌐
Sedai
sedai.io › blog › comparing-aws-lambda-eks-ecs-ecs-factors-in-system-design-and-cost-management
Lambda vs EKS vs ECS vs EC2: A Practical Comparison | Sedai
When choosing between Lambda, EKS, ECS, and EC2, understanding the cost structure is vital for optimizing your cloud expenses. Each service has a unique pricing model, which can affect the overall cost depending on your workload. Here’s a breakdown of how costs are incurred for each: 1. Lambda: Pay-as-You-Go, Beneficial for Intermittent Workloads · AWS Lambda uses a consumption-based pricing model that charges for two factors: the number of requests and the duration of compute time.
🌐
Cloudphilos
cloudphilos.io › post › how-much-more-expensive-is-aws-lambda
How Much More Expensive Is AWS Lambda? A Cost Comparison with EC2
This means we will always be running exactly 1 function 24/7. ... Running this function 24/7 for 1 month will set us back $121,60. 2,29x as expensive as the comparable EC2 compute capacity.
🌐
Medium
medium.com › @moradiyabhavik › aws-compute-services-lambda-vs-ec2-vs-ecs-choosing-the-most-cost-effective-and-highly-available-1cfb410aff1f
AWS Compute Services: Lambda vs EC2 vs ECS — Choosing the Most Cost-Effective and Highly Available Solution | by Bhavik Moradiya | Medium
June 13, 2024 - Choosing between AWS Lambda, Amazon EC2, and Amazon ECS depends on your specific application requirements, traffic patterns, and operational preferences: AWS Lambda is ideal for event-driven, variable workloads where you want minimal operational overhead and cost-efficiency for intermittent usage.
🌐
Mantel
mantelgroup.com.au › home › aws lambda vs. ecs vs. ec2: a comprehensive performance and cost analysis
AWS Lambda vs. ECS vs. EC2: A Comprehensive Performance and Cost Analysis | Mantel | Make things better
June 10, 2024 - The total cost of the test execution was $43.76 for Lambda scenario, $46.76 for ECS scenario and $45.73 for EC2 scenario with over 90% of the total cost were attributed to the use of S3, DynamoDb and API Gateway.
🌐
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...?

🌐
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.
🌐
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 - Who wins out: In this case Lambda can handle the load balancing internally so no extra cost is added, and there is no infrastructure overhead, so Lambda will be cheaper. Amazon EC2: For EC2, you have full control over system-level security.
Find elsewhere
🌐
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...
🌐
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.
🌐
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.
🌐
Stack Overflow
stackoverflow.com › questions › 56274163 › aws-ec2-vs-serverless-cost-comparison
amazon web services - AWS EC2 vs Serverless Cost Comparison - Stack Overflow
So you pay for the compute that is used. 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.
🌐
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.
🌐
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 - Managed security in EC2 instances is time-consuming and allows for human error, which can expose your applications to even more attacks or performance degradation. While AWS Shield can ramp up your defenses, you might not have good cost visibility into your infrastructure while this occurs, leading to cost overruns. Lambda and EC2 offer a pay-as-you-go pricing structure, making them cost-effective alternatives to traditional VM environments.
🌐
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.
🌐
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 ...
🌐
CloudySave
cloudysave.com › aws › ec2 › aws-lambda-pricing-vs-ec2
AWS Lambda Pricing Vs. EC2 - CloudySave
March 31, 2021 - Yet, there are a lot of differences between lambda and EC2 pricing model. ... It charges for every running AWS EC2 instance even when the app or function is not under execution. Pricing per hour is based on the memory amount, performance of the video card, performance of the CPU, and the capacity of the storage which is utilized by EC2 instances. It would be better and cost-efficient for you to rely on AWS EC2 instances in case you’d like to keep your app or function available at all times because it having a great number of regular requests.
🌐
Medium
madurapperuma.medium.com › price-comparison-serverless-lambda-and-ec2-73187763c02d
Price Comparison Serverless Lambda, and EC2 | by gayan madurapperuma | Medium
December 26, 2023 - Let’s assume an application has 5000 hits per day with each execution taking 100 ms with 512MB, so the cost for the lambda function will be 0.16 USD ... 152,083.33 requests x 100 ms x 0.001 ms to sec conversion factor = 15,208.33 total compute ...
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.