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. Answer from re-thc on reddit.com
🌐
Reddit
reddit.com › r/aws › lambda vs ec2
r/aws on Reddit: Lambda vs EC2
August 29, 2021 -

Say that I have 5000 requests hitting an application every 5 seconds and I need to consume an object and write it to a database. Would a lambda with an http trigger that does an insert be more cost effective than having an ec2 instance that does the same thing?

Edit: Just want to say you all are awesome! I am coming from MSFT world and never experienced so many folks being so helpful. Makes me think I should have switched to AWS ages ago. Thanks everybody.

🌐
TechTarget
techtarget.com › searchcloudcomputing › tip › An-overview-of-Amazon-EC2-vs-AWS-Lambda
An overview of Amazon EC2 vs. AWS Lambda | TechTarget
Learn more about EC2 instance family types. AWS Lambda is an event-based service that delivers short-term compute capability. It runs code without the need to deploy, use or manage VM instances.
🌐
Medium
stephanenoutsa.medium.com › amazon-ec2-instances-or-aws-lambda-functions-10efc1ac9d84
Amazon EC2 Instances or AWS Lambda Functions? | by Stéphane Noutsa | Medium
June 27, 2023 - They require a lot of storage space, network connectivity, and computing power to run the application and put it through its paces. This kind of workload requires the ability to adjust resources and configurations, which makes EC2 the best option. AWS Lambda, on the other hand, is the perfect candidate when you only need to use computing resources for small units of time.
🌐
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 - Managing and provisioning the EC2 environment is therefore required. On the other hand, Lambda only needs a few system resources and dependencies to run a specific function.
🌐
CBT Nuggets
cbtnuggets.com › blog › certifications › cloud › aws-lambda-vs-ec2-which-to-use-and-when
AWS Lambda vs EC2: Which to Use and When
Lambda charges the customer per request and duration. EC2, on the other hand, charges the customer for every second the instance is running.
🌐
Medium
medium.com › @repobaby › a-practical-guide-for-when-to-choose-lambda-over-ec2-1173160bd8ec
A practical guide for when to choose Lambda over EC2 | by RepoBaby | Medium
October 1, 2025 - However, debugging Lambda functions can differ after deployment, relying heavily on logs and monitoring services like CloudWatch. Lambda offers seamless, native integrations with a vast array of other AWS services (S3, DynamoDB, API Gateway), making it powerful for building event-driven architectures. EC2 vs.
🌐
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...?

Find elsewhere
🌐
NAKIVO
nakivo.com › cloud › aws lambda vs. amazon ec2: which one should you choose?
AWS Lambda vs. Amazon EC2: Comprehensive Comparison
April 28, 2026 - When using Infrastructure as a service (IaaS) such as AWS EC2, you can manage operating systems on provided virtual machines (EC2 instances). On the Platform as a Service (PaaS) level, you can run your application that must be compiled before running. When using Function as a Service (FaaS) such as AWS Lambda, you don’t need to compile your application – just insert your code in the interface provided by MSP (managed service provider).
🌐
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 - If you need to set up a database like Couchbase or MongoDB, you have to go with EC2. Another example would be a hosting environment for backup and disaster recovery – again, EC2 would be the only choice.
🌐
AWS
aws.amazon.com › blogs › aws › introducing-aws-lambda-managed-instances-serverless-simplicity-with-ec2-flexibility
Introducing AWS Lambda Managed Instances: Serverless simplicity with EC2 flexibility | Amazon Web Services
December 1, 2025 - Run Lambda functions on EC2 compute while maintaining serverless simplicity—enabling access to specialized hardware and cost optimizations through EC2 pricing models, with AWS handling all infrastructure management.
🌐
Sedai
sedai.io › home › 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
March 21, 2026 - Unlike Lambda, which is serverless, EKS provides more control over the orchestration of your containers, making it suitable for larger, more complex applications that require dynamic scaling and high availability.
🌐
Medium
promatics.medium.com › aws-lambda-vs-aws-ec2-how-to-choose-one-over-another-77e6380ac8fc
AWS Lambda Vs AWS EC2: How to choose one over another? | by Promatics Technologies | Medium
January 12, 2021 - Load balancing is handled excellently by Lambda itself. So here, we can see AWS Lambda is a clear winner. ... Businesses that opt for AWS EC2 need to take care of the security layer at the instance level.
🌐
Dashbird
dashbird.io › home › aws lambda vs ec2: a comparative guide
AWS Lambda / EC2: Which Is Best? | Dashbird
July 25, 2023 - Moreover, if your application requires long-running processes, complex computations, or specific operating system configurations, EC2’s flexibility and control over the computing environment make it a better choice. On the other hand, consider a scenario where you’re building a microservices-based application or a real-time file processing system. In this case, AWS Lambda would be a more suitable choice.
🌐
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...
🌐
PureLogics
purelogics.com › aws-lambda-vs-aws-ec2
AWS Lambda vs AWS EC2: What’s Best for Your Use Case?
December 23, 2024 - EC2 instances are designed for steady, long-term use, often operating continuously for weeks or even years. In contrast, Lambda functions are ideal for handling specific event-driven responses, as they run only for the duration needed to complete ...
🌐
Jeevi Academy
jeeviacademy.com › home › blogs › aws › ec2 vs lambda: what’s the difference and when should you use each?
EC2 vs Lambda: What’s the Difference and When Should You Use Each? - Jeevi Academy
February 24, 2026 - You upload your code, define triggers (such as HTTP requests, file uploads, or database updates), and Lambda runs your function automatically. ... You focus purely on your code. ... The biggest difference: EC2 gives you control.
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.

🌐
Awsstudygroup
cloudjourney.awsstudygroup.com
The First Cloud Journey :: The First Cloud Journey
Scaling Applications with EC2 Auto Scaling · Monitoring with Amazon CloudWatch · Hybrid DNS Management with Amazon Route 53 · Command Line Operations with AWS CLI · NoSQL Database Essentials with Amazon DynamoDB · In-Memory Caching with Amazon ElastiCache · Networking on AWS Workshop · Content Delivery with Amazon CloudFront · Edge Computing with CloudFront and Lambda@Edge ·
🌐
Quora
quora.com › How-does-AWS-Lambda-work-and-why-is-it-faster-than-Amazon-Elastic-Compute-Cloud-EC2-instances-for-executing-code-snippets
How does AWS Lambda work and why is it faster than Amazon Elastic Compute Cloud (EC2) instances for executing code snippets? - Quora
Answer: Lambdas work by executing your code on servers that you don’t manage or even see. That is why lambdas are part of the world of serverless computing. Their lifecycle is managed by AWS in that a new instance is created when required and destroyed thereafter.