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

🌐
Reddit
reddit.com › r/aws › lambda vs ec2 costs for api
r/aws on Reddit: Lambda vs ec2 costs for API
January 12, 2023 -

Hi everyone I have a question regarding cost between lambda and ec2 I am building a simple node application using puppeteer that will only act as an api. Obviously don’t expect heavy usage for now but overall Iv read that lambda will be cheaper to run up until heavy usage? Just wanted to get your thoughts if ec2 is better than lambda both in performance and cost. Again this will not be heavily used in either case. Also which ones performance will be better?

🌐
Reddit
reddit.com › r/aws › lambda is the most expensive part of a project, is this normal? when to choose lambda / ec2.
r/aws on Reddit: Lambda is the most expensive part of a project, is this normal? When to choose lambda / Ec2.
August 30, 2023 -

Hello, pretty new to building on AWS so I pretty much just threw everything in lambda for the heavy compute and have light polling on EC2. I am doing all CPU and somewhat memory intensive work that lasts around 1-7 minutes on async lambda functions, which sends a webhook back to the polling bot (free t2 micro) when it is complete. For my entire project, lambda is accruing over 50% of the total costs which seems somewhat high as I have around 10 daily users on my service.

Perhaps it is better to wait it out and see how my SaaS stabilises as we are in a volite period as we enter the market, so it's kinda hard to forecast with any precision on our expected usage over the coming months.

Am I better off having an EC2 instance do all of the computation asynchronously or is it better to just keep it in lambda? Better can mean many things, but I mean long term economic scalability. I tried to read some economics on lambda/EC2 but it wasn't that clear and I still lack the intuition of when / when not to use lambda.

It will take some time to move everything onto an ec2 instance first of all, and then configure everything to run asynchronously and scale nicely, so I imagine the learning curve is harder, but it would be cheaper as a result? .

🌐
Reddit
reddit.com › r/aws › eli5: aws lambda vs ec2
r/aws on Reddit: ELI5: AWS Lambda vs EC2
April 28, 2019 -

I know that there's a trend towards serverless architecture like Lambda.

I know Lambda is an on demand AWS service where you don't have to provision and allocate resources(EC2) based on forecasting. With Lambda, your compute resources can scale based on real-time demands.

In what situations would you want to use a non managed solution like EC2 vs lambda?

I'm under the impression that the less work you need to do in terms of operations the better - why AWS exists. If you use ec2 directly, you would have to define autoscaling rules, etc

Top answer
1 of 2
9
At a certain scale the more-expensive-but-managed nature of Lambda is more expensive than hiring people to manage a 100% CPU utilization EC2 fleet. My understanding of the pricing model is that you get more CPU cycles for a $1 on EC2 than on Lambda. Most people still go with Lambda because their workload is bursty or they really value the managed "serverless" nature of Lambda. But if you're at the point and have the engineering/operations capacity to architect and manage the same solution on EC2 your costs will be cheaper. It's kind of like the same argument for On-Premise vs Cloud. At certain scales and for certain workloads it is cheaper to run it yourself, but that comes at the inconvenience of, well, running it yourself. Many people would rather pay more for less to deal with.
2 of 2
2
Lambda and EC2, while technically achieving similar outcomes from a user perspective, are entirely different infrastructure concepts. An EC2 instance is, fundamentally, a computer. It runs a common Operating System, reads and writes to disks, and performs whatever tasks you may declare for it. We often use computers to run interpreters (like Python) and web hosts (like Apache) in order to provide an accessible application (like a website, or an API). Lambda, however, basically starts where the previous paragraph ends. Instead of using a computer we configure specifically to run our application, we simply provide our application code to Lambda, which has its own interpreter (because it's just another computer, but one we don't have to care about). A Lambda function exists for only as long as it takes to run the code you've given it. And is billed for accordingly. I must point out that the biggest difference between Lambda and EC2 is not scaling based on forecast vs scaling based on real-time demands. EC2 also scales based on real-time demands, but it takes longer to do so, because it requires the booting up of more "computers". Lambda is just running your code, and can do so concurrently. Lambda just scales better than EC2 as a side effect of being what Lambda is. EC2 is persistent (sure you can shut it off, but it bills by the hour). If your anticipated workload is mostly static, or has predictable spikes, EC2 is generally going to work out cheaper as you can purchase RIs or utilize compute saving plans. Lambda is interesting, as it can save quite a lot of money when utilized correctly, but can also end up costing a huge amount when misused. Personally, I've found that going "pure-Lambda" makes the most sense when your workloads are actively generating revenue while running. For example, a Lambda function that processes a financial transaction on your platform, of which you take a percentage cut. Because Lambda only costs money when it is actively running, and when it is actively running it is generating revenue, you can express your infrastructure budget as a percentage of your revenue. This holds true for other "serverless" offerings, such as On-Demand DynamoDB, Serverless Aurora, etc. Serverless makes sense when the work it does while active generates enough revenue to cover the cost of running it. With EC2, you're paying for it all the time (even when it isn't directly making you money), but you can generally determine what your baseline monthly cost is going to be. This will also obviously increase as usage of your platform increases, but not at the same ratio. I'm under the impression that the less work you need to do in terms of operations the better - why AWS exists This is generally accurate, but when we say "less work" we mean "reduced recurring administrative complexity". Defining autoscaling rules is something you have to do once, maybe refining it a bit over time. The initial outlay of labour required to build a solution should not be the primary metric to determine its feasibility. It may make sense to put in the initial work to build a more complex system that is better suited to one's needs if that reduces administrative/financial overhead in future. tl;dr: There is no magic silver bullet that is both infinitely scaleable and relatively cheap. Every decision regarding infrastructure is nuanced and extremely context-specific. The best way to improve scaling and lower costs is to gain an in-depth understanding of what exactly you need, and how best AWS can provide it.
🌐
Reddit
reddit.com › r/python › cost analysis for python scripts - aws ec2 vs aws lambda
r/Python on Reddit: Cost analysis for python scripts - AWS EC2 vs AWS Lambda
February 19, 2016 -

So I decided AWS Lambda had been on the field enough time to make an analysis by my own.

Lambda comes with a few problems like only Python 2.7 (they will fix it in the future I guess), libraries, etc. Also I had read some blogs like Flynn's one.

But skipping those problems I wanted to know... What about money?

Please check my numbers to see if I made something wrong.

I will compare t2.nano (1 cpu + 512 MB) and Lambda 128 MB

With 2 SSH consoles opened targeting my EC2 instance, I had 139 MB left, and this was the first +1 to EC2.

So, I designed a small task which runs a regex pattern to catch the attributes within div tags from a html code. The input file's size was 322 KB and the same task run 1000 times:

import re, time

def task(code):
    rep = 1000
    pattern = '<div([^>]+)>'
    ini = time.time()
    for i in range(rep):
        results = re.findall(pattern, code)
    message = "{0} Repetitions. Avg = {1:.3f} ms".format(rep, (time.time()-ini)*1000/rep)
    print(message)

This task only took 30 MB in both cases, and here I saw the first surprise:

  • Lambda: 1000 Repetitions. Avg = 7.261ms

  • EC2: 1000 Repetitions. Avg = 0.480 ms

From AWS Cloud Watch: Duration: 7823.48 ms Billed Duration: 7900 ms Memory Size: 128 MB Max Memory Used: 30 MB

Lambda took 562 ms to get the file from S3, import the libraries and so on, and to run the task 1000 times 7.261 seconds, 15 times more.

So, for small fast tasks, you are paying 562 ms at every call, and for heavy tasks you will be 15 times slower.

I didn't test a group of EC2 machines for a long time, probably the efficiency it drops down a lot for heavy load work. In Digital Ocean I had this problem. I contact them saying that some of my machines were 5 times slower than others, and their reply was something like: "Please tell us which ones and we will move to another server". This solution is not tolerable when you are working with an auto scaling cloud.

Let's say EC2 instances needs also 562ms to get the file from S3, import libraries and so on. So I designed 2 functions to calculate the cost price:

import math

def lambda_cost(mem=128,runtime=7,num_calls=10000000, free_gbs=400000, free_calls=1000000, loading_data_time=562):

    '''
    runtime and loading_data_time in ms
    '''
    price =  0.00001667
    billed_time = math.ceil( (runtime+loading_data_time)/100 ) * 100
    total_seconds_runtime = num_calls*billed_time/1000
    total_gbs = total_seconds_runtime * mem / 1024
    charged_by_runtime = max(0, (total_gbs-free_gbs)*price)
    charged_by_calls = max(0.2 * ((num_calls-free_calls)/1000000), 0)
    print('Billed time: {0}'.format(billed_time))
    print('GB/s: {0}'.format(total_gbs))
    print('Charged by runtime: ${0:.3f}'.format(charged_by_runtime))
    print('Charged by calls: ${0:.3f}'.format(charged_by_calls))
    print('Total charged: ${0:.3f}'.format(charged_by_runtime + charged_by_calls))
    

def ec2_cost(mem=512, runtime=0.48, num_calls=10000000, free_hours=750, loading_data_time=562, cost_hour=1):
    '''
    runtime and loading_data_time in ms
    '''     
    costs = {
        512: [0.0065, 0.0045],
        1024: [0.013, 0.009],
    }
    if not costs.get(mem): return False
    on_demand_hour = costs[mem][0]
    reserved_hour = costs[mem][1]
    total_runtime_seconds = (runtime + loading_data_time) * num_calls / 1000
    total_runtime_hours = total_runtime_seconds / 3600
    total_cost_on_demand = (total_runtime_hours - free_hours) * on_demand_hour
    total_cost_reserved = (total_runtime_hours - free_hours) * reserved_hour
    print('Cost on demand: ${0:.3f}'.format(total_cost_on_demand))
    print('Cost reserved: ${0:.3f}'.format(total_cost_reserved))

Now, what if we want to run 10kk times this script?

  • Lambda with 400k Free GBs and 1kk Free calls: $5.551

  • Lambda without Free GBs nor Free calls: $12.419

  • EC2 with 750 free hours + on demand: $5.281

  • EC2 with 750 free hours + reserved: $3.656

  • EC2 + on demand: $10.156

  • EC2 + reserved: $7.031

And 100kk times?

  • Lambda with 400k Free GBs and 1kk Free calls: $117.320

  • Lambda without Free GBs nor Free calls: $124.188

  • EC2 with 750 free hours + on demand: $96.684

  • EC2 with 750 free hours + reserved: $66.935

  • EC2 + on demand: $101.559

  • EC2 + reserved: $70.310

EC2 750 free hours is for t2.micro, not t2.nano (1GB instead of 512MB), but only for new accounts (less than 1 year old). In the other hand, Lambda 400k free GBs are for everyone, being this one of the few positive vote it gets.

Another point is that EC2 performance may be improved by multithreads in some cases. It will not help with the regex task, for example, but it's very useful for urllib and so on. Something like this:

import os
import threading
from subprocess import Popen
import urllib2, time

def ec2_loading_data_time(url='http://www.nytimes.com/'):
    ini = time.time()
    response = urllib2.urlopen(url)
    code = response.read().decode('utf-8')
    loading_data_time = time.time() - ini
    print('Loading data time: {0}'.format(loading_data_time))
    return code


class TestingThreadPerformance(threading.Thread):
    def run(self):
        ini = time.time()
        code = ec2_loading_data_time(url)
        task(code)
        print('Total thread time = {0:.3f}'.format(time.time()-ini))


for i in range(10): TestingThreadPerformance().start()

Also EC2 can be loaded with full custom systems. Any project you already have or get will work. Learning curve + Surprises = 0.

My conclusion is that Lambda doesn't worth the cost. It's not only more expensive, but rigid, fragile and poor documented.

In my opinion you should use it only in small projects that needs less than 400k GBs and 1kk calls.

P.D. I repeat, I didn't tested this on a heavy load work for a long time, not in the EC2 nor in the Lambda block.

......................................... UPDATE ............................................

I forgot to talk about EC2's prices vs Lambda.

Lambda has no discounts by quantity. If you want 1.000.000.000 tasks, this will cost 1.000 times more than 1.000.000 tasks, and you can't reserve resources to make it cheaper. Lambda calculator

EC2 instead has 3 different options:

  • On demand: Take it when you want, and even with this you get a 20% cheaper price than with Lambda.

  • Reserved resources: You specify when you will need and how many machines, and you get a 40% cheaper price than with Lambda.

  • Spot instances: You choose the price and it will run when free resources are available. They can take it from you at any moment, not like the other 2, but it's much cheaper and If you don't finish the hour, you get that hour for free

Another thing I want to highlight again, EC2 has more resources you can exploit with multithreading. How? While you are taking a new file, process the current one. Just with this you can cut a 25%-50% the price independently of the previous discounts.

......................................... UPDATE 2 ............................................

Anyone who wants to test Lambda for free without registration can do it here.

Replying here a few new questions:

  • EC2 also can be autoescaling + autobalancing.

  • If you make a Docker from the official Ubuntu repository, you will get the latests updates everytime it compiles. Also, you can keep your EC2 instances without a public IP, so nobody can get in = NO SECURITY ISSUES.

  • With supervisord and celery, a task can check for changes in your E3, etc, so it's like a trigger.

  • You can make a svn folder for your .py scripts, and tell supervisord to run everything from there. Later syncrhonize it with your Github, SVN, etc, so you nor your team need to login in AWS.

  • You can reserve SWAP memory to avoid crashes in case of a unexpected big task. In Lambda if you make it too small it will crash, and if too big you waste money.

  • You can run any library, no need even a pure python one. As u/kakamaru pointed in his reply, you can skip this limitation in lambda with something like lambda-packages. I don't know how many limitations this has anyhow.

  • EC2 Instances can be limited by permissions, for example, read-only for Database A, Write for S3 folder /result/. So even code errors or hacks will not cause problems.

  • If you don't know how to do something Google it or ask for help. Many people know Ubuntu, few know Lambda.

🌐
Trek10
trek10.com › homepage › blog listing › aws lambda pricing in context - a comparison to ec2
AWS Lambda vs EC2 Cost Comparison - Trek10 | Trek10
This is a simple analysis with ... would typically run on an instance with 2 vCPUs and 8 GB of RAM, before Lambda costs are similar to EC2 costs....
Price   $
Address   1400 E. Angela Blvd, Suite 209, 46617, South Bend
🌐
Cloudphilos
cloudphilos.io › post › how-much-more-expensive-is-aws-lambda
How Much More Expensive Is AWS Lambda? A Cost Comparison with EC2
... 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.
Find elsewhere
🌐
Reddit
reddit.com › r/aws › when is ec2 more cost effective than lambda?
When is EC2 more cost effective than Lambda? : r/aws - Reddit
November 3, 2017 - On the pure infrastructure cost, EC2 is much cheaper. The difference is how effectively your resources are used. The advantage of Lambda (and most serverless services) is that you don't pay for idle resources. If your Lambda isn't actively handling a request, you don't pay anything, whereas ...
🌐
Reddit
reddit.com › r/aws › aws announces lambda managed instances, adding multiconcurrency and no cold starts
r/aws on Reddit: AWS announces Lambda Managed Instances, adding multiconcurrency and no cold starts
3 weeks ago - Note that unlike traditional · Lambda functions, you are not charged separately for execution duration per request. The multiconcurrency feature helps further optimize costs by reducing the total compute time required to process your requests."
🌐
Dzhuneyt's Blog
dzhuneyt.com › post › aws-lambda-vs-aws-ec2-cost
AWS Lambda vs AWS EC2 - Cost Comparison - Dzhuneyt
November 13, 2024 - A Lambda configured with 10GB of memory costs 10x more than a Lambda configured with 1GB of memory. This makes total sense, since the same thing applies if you compare running a smaller EC2 instance VS a larger one, but because Lambda makes ...
🌐
Reddit
reddit.com › r/aws › ec2 or lambda
r/aws on Reddit: EC2 or Lambda
February 28, 2025 -

I am working on a project, it's a pretty simple project on the face :

Background :
I have an excel file (with financial data in it), with many sheets. There is a sheet for every month.
The data is from June 2020, till now, the data is updated everyday, and new data for each day is appended into that sheet for that month.

I want to perform some analytics on that data, things like finding out the maximum/ minimum volume and value of transactions carried out in a month and a year.

Obviously I am thinking of using python for this.

The way I see it, there are two approaches :

  1. store all the data of all the months in panda dfs

  2. store the data in a db

My question is, what seems better for this? EC2 or Lambda?

I feel Lambda is more suited for this work load as I will be wanting to run this app in such a way that I get weekly or monthly data statistics, and the entire computation would last for a few minutes at max.

Hence I felt Lambda is much more suited, however if I wanted to store all the data in a db, I feel like using an EC2 instance is a better choice.

Sorry if it's a noob question (I've never worked with cloud before, fresher here)

PS : I will be using free tiers of both instances since I feel like the free tier services is enough for my workload.

Any suggestions or help is welcome!!
Thanks in advance

🌐
Reddit
reddit.com › r/aws › lambda vs ec2 vs locally running
r/aws on Reddit: Lambda vs EC2 vs locally running
April 14, 2020 -

Hi guys, I'm extremely new to AWS. I watched a few of the Amazon AWS training modules and was introduced to Lambda and EC2. From my understanding, they are both computing services. I googled what the difference was between the two and what I read was that Lambda is used for smaller and quicker executions whereas EC2 is used for more high-performance executions. But why would you get lambda in the first place if all you're doing is computing simple tasks? Wouldn't it be easier to compute it locally? I would appreciate if someone could give examples of what kind of situation you would use each kind of resource. Sorry if the question is a bit elementary, I was just introduced to the subject.

Top answer
1 of 5
3
If you're trying to create scalable, resilient, and maintainable processes, little to none of it should be happening "locally." I'm not sure what field you're in, what your background is, or what your definition of "computing" is. But keep in mind for a lot of people running in AWS, that's handling web requests (i.e. "running websites"), performing BI analyses (piping terabytes of data between different AWS services for later heavier computations and queries), backend processes (could be anything really...image processing, web scrapers, e-commerce backoffice stuff, etc), or operational tasks to support those things (backups, scaling, patching, maintenance, deployments). None of that should be running "locally" on one person's workstation. Or if you mean "locally" as on-prem servers or VMs, then that's a decision for your organization to make about where you want to run different workloads.
2 of 5
1
We've all got to start somewhere! The thing that made the cloud click for me was understanding what AWS is actually offering in EC2 and Lambdas. If you're not already familiarise yourself with the different service models that the cloud in general provides, these are classified under the descriptor: 'XYZ as a service' . The key takeaway is the separation of responsibility between the cloud provider and the client for each service. For example EC2 are considered as Infrastructure as a Service, because AWS provide the computational infrastructure, but the client needs to control the rest of the configuration of the instance. Lambdas are classified as Platform as a Service as they abstract away the environment and the configuration and for all intents and purposes allow the client to run code fairly cleanly. Finally running code locally requires the user to acquire the hardware, configure the hardware, configure the environment, write, execute the code, then maintain all of the levels of the stack. Each has it's own trade offs and being able to determine how each of those apply to a certain project impact what type of service you utilise. Now to answer your question about why use lambdas, I personally love working with serverless projects for a number of reasons. First because I prefer to abstract away a lot of the complexity that comes along with running middleware (such as Kubernates) that is required when creating the same projects that I am running as Lambdas. I find it speeds up my development times, its very easily scalable and finally reasonably cost effective. Any other questions, feel free to ask.
🌐
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) costs $0.0042/hour. I’m ...
🌐
Reddit
reddit.com › r/aws › using lambda vs ec2 for a backend
r/aws on Reddit: Using Lambda vs EC2 for a backend
September 9, 2018 -

Hello everyone, I was studying for my AWS CSAA exam and while I’ve sightly used both services and played around with them in lab environments, I can’t wrap my head around one question. When would I use a EC2 over a Lambda when Lambda is much cheaper and still provides scalability for a backend solution. For most simple web apps, a REST API served thru Lambda seems like a great option (esp when utilizing AWS API Gateway). When would I directly use EC2 (as well as ELB, ASG,etc)? I guess I’m trying to understand stand when a “serverless” web app makes sense. Thanks everyone for your time

EDIT: added serverless clarification

🌐
Reddit
reddit.com › r/aws › lambdas vs ec2
r/aws on Reddit: Lambdas vs EC2
September 19, 2022 -

Hey, everyone! I’m doing a small side project were I need to run a browser, login, click a button and that’s it. Maybe take a screenshot here and there but that’s about it. I’ve been debating myself with which one should be good for my use case. Lambdas seem like a good approach but I’m not so sure about scalability, whereas on the other hand we have EC2 and more memory to scale

🌐
Reddit
reddit.com › r/aws › what is the cost and performance difference between a s3 + lambda combo vs ec2 instance for hosting a portfolio website?
r/aws on Reddit: What is the cost and performance difference between a S3 + Lambda combo vs EC2 instance for hosting a portfolio website?
December 23, 2023 -

I am currently building my portfolio as a gamedev and I am relatively new to AWS. It is a mostly static website, but it does need to demo some interactive features that use Node. So would S3 for the static components and Lambda for the more interactive node-based stuff be more cost effective than having a EC2 instance running 24/7? Would performance be considerably different between the two? Is there a secret third option that solves all my problems and is cheap and is perfect and amazing and everything? Am I worried about latency issues for nothing with the S3 and Lambda or is it not perceptable for an end user?

🌐
Reddit
reddit.com › r/devops › reducing and predicting ec2 and lambda costs?
r/devops on Reddit: Reducing and predicting EC2 and Lambda costs?
May 22, 2025 -

Currently part of a small startup and these aws costs are part of what can make the difference between a green month and a red month.

Currently we have a mix of EC2 instances (mostly t3.medium and m5.large) and we use lambda primarily for data processing. Our monthly range is giga wide like 2k - 10k a month mainly because of how our service works and demand spikes.

We've already tried turning off unused instances and monitoring through CloudWatch but the spend is going crazy, we onboarded with Milkstraw recently, which is a tool similar to PUMP that should help us with these costs and so far over our first week it's looking better than before but I would still love some advice or tips on getting these costs down, maybe some strategies or optimization tips.

I know that hiring someone full time to optimize and monitor this should be the way but we are suuuper bootstrapped right now.

🌐
Reddit
reddit.com › r/aws › how we reduced lambda functions costs by thousands of dollars
r/aws on Reddit: How we reduced Lambda Functions costs by thousands of dollars
June 20, 2019 - All the time you saved in server maintenance you spend on gathering analytics and setting up custom monitoring to control cost. For a few thousand moneys a day you can run a whole bunch of fat instances much cheaper and with less custom engineering. ... There is a point where using a lambda is pointless. If you have a task you execute on occasion be it cronjob or queue consumption it's perfectly fine. Just don't make your lambda do high request volume. Note I mean constant high request. ... We're already used Dockerized microservices and classic EC2 instances.