Very high estimates for AWS Lambda

161 views
Skip to first unread message

Mathilda

unread,
Dec 11, 2021, 7:23:59 AM12/11/21
to Cloud Carbon Footprint
Hello,

I ran the CCF calculator (the CLI version) towards my team's AWS accounts and the carbon footprint was quite low for all services except AWS Lambda. There, the estimates seemed impossibly high, so I decided to look at a particular date for one of our accounts (the account with the least activity, to save some time) and go through the steps in the code manually. I also checked the documentation for some explanation of the calculations, and I did find some parts a bit puzzling.

So, the first thing I did was go to Cloudwatch insights and run the query

filter @type = "REPORT"
| fields datefloor(@timestamp, 1d) as Date, @duration/1000 as DurationInS, @memorySize/1000000 as MemorySetInMB, 2.12 * DurationInS/3600 * MemorySetInMB/1792 as wattsPerFunction
| stats sum(wattsPerFunction) as Watts by Date
| sort Date asc

against all lambda log groups for the day in question (2021-12-01).

So here my first question is: Shouldnt't it be called wattHoursPerFunction, and the end result wattHours, since the duration in hours is there in the calculation?

Anyway, the end result was that the number of watt hours was 59.5026

The number of kilowatt hours was then set as 59.5026 Wh * 1.13 (PuE for AWS) = 67.535451 (kWh)

This is the number that ended up in the results csv file when running the CLI app, under the "Lambda kilowatt hours" column.

This I don't understand. The PuE is a unit-less factor as far as I'm aware, so how can something with the unit Wh multiplied by a unit-less factor get the unit kWh? Shouldn't the calculation be

(E(Wh) * PuE)/1000

with the result here being 0.06754?

Then the CO2e estimate was set as

67.535451 (kWh) * 0.000316 (grid emissions factor in AWS region eu-west-1 [metric ton / kWh]) = 0.021341 ton CO2e

This was the result in the csv file under the column "Lambda metric tons CO2e Emissions".

So the end result is 0.021341 ton CO2e, or 21.34 kg CO2e, for AWS Lambda in that account, whereas I think the result should be

0.067535451 (kWh) * 0.000316 (grid emissions factor in AWS region eu-west-1 [metric ton / kWh]) =  0.000021341 ton CO2e = 0.021341 kg CO2e

I.e. the end result is off by a factor of a thousand.

Am I in the wrong here? Did I misunderstand something, or is there indeed an error?

The reason I started digging was that the end result for all of the lambdas in our production account was a whopping 8 tons CO2e for just a week. That seemed awfully high, considering the specifics of our account.

Regards, Mathilda


Dan Lewis-Toakley

unread,
Dec 14, 2021, 2:47:54 PM12/14/21
to Mathilda, Cloud Carbon Footprint
Hi Mathilda, 

Thank you so much for raising this issue, and providing all the details.

You are absolutely correct, our Lambda implementation when using Cloudwatch and that query was not converting watt-hours to kilowatt-hours. This is likely because we started out using watt-hours for the project then converted to kilowatt-hours and it seems our Lambda implementation was missed when we did this. 

I've pushed a fix for this, which you can test out if you pull the latest from the trunk branch. We'll get this published soon as well, in case you are using the create-app version of the code. 

Best,
Dan  

--
We're excited to hear from you and hope you're enjoying Cloud Carbon Footprint.
Please fill out our feedback form: https://forms.gle/nFzkRioryy4R1DGB6
Add your name to ADOPTERS.md: https://github.com/cloud-carbon-footprint/cloud-carbon-footprint/blob/trunk/ADOPTERS.md
Give us a star on the github if you're enjoying the tool!
---
You received this message because you are subscribed to the Google Groups "Cloud Carbon Footprint" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-carbon-foot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-carbon-footprint/ecb4bc65-2397-4746-8120-2b19ea6623acn%40googlegroups.com.


--
Dan Lewis-Toakley
Green Cloud Lead, North America
Pronouns He/Him
Email dan.lewi...@thoughtworks.com
Telephone +19172545068
ThoughtWorks
Reply all
Reply to author
Forward
0 new messages