Guides
Tutorials
Calculate Cloud Carbon Footprint

How to calculate the carbon emission of your cloud services

Understanding and calculating the carbon footprint of your cloud services has never been simpler. This tutorial will walk you through using Climatiq API to assess emissions based on a variety of cloud computing factors.

‚ö†ÔłŹ
Subscription plan required

Cloud feature is available as an add-on to our Corporate or Commercial tier (opens in a new tab).

Key Considerations in Cloud Carbon Emissions

Cloud computing power utilization depends on several factors:

  • The CPU, Memory, and Storage demand of your services
  • How well utilized the machines in the data centers are used.
  • Efficiency in data centers regarding cooling and electricity usage, usually denoted as Power Usage Effectiveness (opens in a new tab) or PUE.
  • Where the data centers are located to determine the electricity grid mix.
  • The embodied emissions, meaning the emissions related to the manufacturing and disposal of the physical components.

With these factors in mind, let's explore different types of services and how Climatiq can help you calculating your emissions.

Carbon Emissions for Virtual Machines

Several services let you rent a Virtual Machine (VM) in the cloud, such as GCP's Compute Engine, Azure Virtual Machines, or AWS's EC2 instances. Other services might also be backed by a VM that you designate, like Azure's App Service or Kubernetes clusters.

For all instances where your workload runs on a specific VM, Climatiq provides a Virtual Machine Endpoint where you need to put in the region you're running, instance type, and optionally, the CPU load of the instance. This will automatically compute the electricity used for memory and CPU usage, and embodied emissions for the specified instance type.

Virtual Machines Example

Here is an example of renting a t2.nano from AWS for 24 hours in the "us west 2" region. For more information about this endpoint, we refer to the API reference documentation.

Request

curl --request POST \
--url https://beta4.api.climatiq.io/compute/aws/instance \
--header 'Authorization: Bearer API_KEY' \
--data '{
"instance": "t2.nano",
"region": "us_west_2",
"duration": 24,
"duration_unit": "h"
}'

Response

{
"total_co2e": 0.038731613137886506,
"total_co2e_unit": "kg",
"memory_estimate": {
"co2e": 0.001570062789086502,
"co2e_unit": "kg",
"co2e_calculation_method": "ar4",
"co2e_calculation_origin": "source",
"emission_factor": {
"name": "Electricity supplied from grid",
"activity_id": "electricity-supply_grid-source_supplier_mix",
"id": "7518e461-7980-47ab-89f1-5f126dde33a9",
"access_type": "public",
"source": "EPA",
"source_dataset": "eGRID",
"year": 2022,
"region": "US-NWPP",
"category": "Electricity",
"source_lca_activity": "electricity_generation",
"data_quality_flags": []
},
"constituent_gases": {
"co2e_total": 0.001570062789086502,
"co2e_other": null,
"co2": 0.0015601279323868027,
"ch4": 1.43318763700224e-7,
"n2o": 2.293100219203584e-8
},
"activity_data": {
"activity_value": 0.00573275054800896,
"activity_unit": "kWh"
},
"audit_trail": "enabled"
},
"cpu_estimate": {
"co2e": 0.0158160103488,
"co2e_unit": "kg",
"co2e_calculation_method": "ar4",
"co2e_calculation_origin": "source",
"emission_factor": {
"name": "Electricity supplied from grid",
"activity_id": "electricity-supply_grid-source_supplier_mix",
"id": "7518e461-7980-47ab-89f1-5f126dde33a9",
"access_type": "public",
"source": "EPA",
"source_dataset": "eGRID",
"year": 2022,
"region": "US-NWPP",
"category": "Electricity",
"source_lca_activity": "electricity_generation",
"data_quality_flags": []
},
"constituent_gases": {
"co2e_total": 0.0158160103488,
"co2e_other": null,
"co2": 0.015715931678400002,
"ch4": 0.0000014437200000000002,
"n2o": 2.309952e-7
},
"activity_data": {
"activity_value": 0.0577488,
"activity_unit": "kWh"
},
"audit_trail": "enabled"
},
"embodied_cpu_estimate": {
"co2e": 0.02134554,
"co2e_unit": "kg",
"co2e_calculation_method": "ar4",
"co2e_calculation_origin": "source",
"emission_factor": {
"name": "AWS - Embodied emissions - t2.nano - Xeon E5-2676 v3",
"activity_id": "cpu-provider_aws-type_t2.nano_xeon_e5_2676_v3",
"id": "7a8ff5fd-3361-427b-aedf-e47a5e49ea82",
"access_type": "public",
"source": "CCF",
"source_dataset": "Derived from CCF models",
"year": 2021,
"region": "GLOBAL",
"category": "Cloud Computing - CPU",
"source_lca_activity": "upstream-end_of_life",
"data_quality_flags": [
"notable_methodological_variance"
]
},
"constituent_gases": {
"co2e_total": 0.02134554,
"co2e_other": null,
"co2": null,
"ch4": null,
"n2o": null
},
"activity_data": {
"activity_value": 24,
"activity_unit": "instance-hour"
},
"audit_trail": "enabled"
},
"calculation_details": {
"instance": "t2.nano",
"instance_memory": 0.536870912,
"memory_unit": "GB",
"vcpu_cores": 1,
"average_vcpu_utilization": 0.5,
"power_usage_effectiveness": 1.135,
"energy_used_cpu": 0.0577488,
"energy_used_memory": 0.00573275054800896,
"energy_unit": "kWh"
}
}
Selecting electricity emission factors

When viewing or overriding electricity emission factors, a number of aspects need to be taken into account including; what particular mix of energy is being provided by the source, whether the factor includes upstream emissions and whether it includes transmission and distribution losses. This information is encoded in the activity_id and the source_lca_activity fields provided in API response. More information can be retrieved from the issuing source. Read more about selecting electricity EFs here.

Carbon Emissions for Other Services

For many services, you aren't renting a complete VM, but instead, leasing some storage, memory, or CPU power. Even in these cases, Climatiq can assist you. Endpoints are available for estimating emissions based on storage reserved, memory available or virtual CPU power used

Depending on the service, obtaining these metrics might pose different levels of difficulty. This guide doesn't cover the specifics of retrieving these metrics, but a good starting point could be your cloud provider's monitoring systems or your billing/usage data. If you need further assistance, refer to this document (opens in a new tab), or your cloud provider's documentation.

Let's take a couple of examples of how we can use the Climatiq endpoints to measure based on this more granular input.

CPU Example: Serverless Functions

If you are running serverless functions, you are often able to retrieve the CPU usage from monitoring or billing. Let's consider an AWS Lambda function with the following specifications:

The emissions from this function's CPU usage can be calculated using Climatiq's CPU endpoint like this.

Request

curl --request POST \
--url https://beta4.api.climatiq.io/compute/aws/cpu \
--header 'Authorization: Bearer API_KEY' \
--data '{
"cpu_count": 1,
"region": "us_west_2",
"duration": 200,
"duration_unit": "ms"
}'

Response

{
"co2e": 3.661113506666668e-8,
"co2e_unit": "kg",
"co2e_calculation_method": "ar4",
"co2e_calculation_origin": "source",
"emission_factor": {
"name": "Electricity supplied from grid",
"activity_id": "electricity-supply_grid-source_supplier_mix",
"id": "7518e461-7980-47ab-89f1-5f126dde33a9",
"access_type": "public",
"source": "EPA",
"source_dataset": "eGRID",
"year": 2022,
"region": "US-NWPP",
"category": "Electricity",
"source_lca_activity": "electricity_generation",
"data_quality_flags": []
},
"constituent_gases": {
"co2e_total": 3.661113506666668e-8,
"co2e_other": null,
"co2": 3.6379471477777794e-8,
"ch4": 3.3419444444444453e-12,
"n2o": 5.347111111111112e-13
},
"activity_data": {
"activity_value": 1.336777777777778e-7,
"activity_unit": "kWh"
},
"audit_trail": "enabled"
}

Memory Example: Serverless Functions

To account for the carbon emissions linked to memory (RAM) usage, one must consider both the allocated and the actually used memory.

Even if the full memory isn't used, it still consumes power. a good rule of thumb is to use the total amount of RAM you have allocated, not just the amount you use.

For our AWS Lambda function, consider the following specification:

  • Function runtime: 200ms
  • Memory allocated: 1792MB

The emissions from this function's memory usage can be calculated using Climatiq's Memory endpoint like this.

Request

curl --request POST \
--url https://beta4.api.climatiq.io/compute/aws/memory \
--header 'Authorization: Bearer API_KEY' \
--data '{
"region": "us_west_2",
"data": 1792,
"data_unit": "MB",
"duration": 200,
"duration_unit": "ms"
}'

Response

{
"co2e": 1.2131134143146666e-8,
"co2e_unit": "kg",
"co2e_calculation_method": "ar4",
"co2e_calculation_origin": "source",
"emission_factor": {
"name": "Electricity supplied from grid",
"activity_id": "electricity-supply_grid-source_supplier_mix",
"id": "7518e461-7980-47ab-89f1-5f126dde33a9",
"access_type": "public",
"source": "EPA",
"source_dataset": "eGRID",
"year": 2022,
"region": "US-NWPP",
"category": "Electricity",
"source_lca_activity": "electricity_generation",
"data_quality_flags": []
},
"constituent_gases": {
"co2e_total": 1.2131134143146666e-8,
"co2e_other": null,
"co2": 1.205437219441778e-8,
"ch4": 1.1073564444444446e-12,
"n2o": 1.7717703111111112e-13
},
"activity_data": {
"activity_value": 4.429425777777778e-8,
"activity_unit": "kWh"
},
"audit_trail": "enabled"
}

Combining the CPU and memory usage for this serverless function will then give you a good idea of the use phase emissions.

Storage

Storage in cloud computing not only consumes power but also varies in terms of the backing hardware and replication strategies.

To calculate storage emissions, consider the following aspects:

  1. The type of hardware backing your storage: HDDs generally consume less power but are slower than SSDs.
  2. Calculate emissions based on storage purchased, not just used. Even if you're not using the storage, having it available will use electricity.
  3. Replication: storage is often duplicated across multiple machines or data centers. If your storage is replicated you should take your storage amount and multiply it by how many times it's replicated. You'll have to look at your cloud provider and the specific services you use to figure out how many times data is replicated. Here's a list of list of replication factors (opens in a new tab), which covers many services for all the major cloud providers.

Two examples are presented below, one considering SSD instance storage on EC2 and the other taking into account usage of S3 for file storage. Each case illustrates how these factors affect carbon emissions calculations.

Storage Example 1. An SSD EC2 Instance Storage

In this example, we mount a 20GB SSD instance storage on our EC2 instance, and we want to calculate the emissions over a week.

Looking at the AWS replication factors (opens in a new tab), the EC2 Instance Storage is not replicated. This means we only have estimate with the data we've purchased.

Request
curl --request POST \
--url https://beta4.api.climatiq.io/compute/aws/storage \
--header 'Authorization: Bearer API_KEY' \
--data '{
"region": "us_west_2",
"data": 20,
"data_unit": "GB",
"storage_type": "ssd",
"duration": 7,
"duration_unit": "day"
}'
Response
{
"co2e": 0.00125334421632,
"co2e_unit": "kg",
"co2e_calculation_method": "ar4",
"co2e_calculation_origin": "source",
"emission_factor": {
"name": "Electricity supplied from grid",
"activity_id": "electricity-supply_grid-source_supplier_mix",
"id": "7518e461-7980-47ab-89f1-5f126dde33a9",
"access_type": "public",
"source": "EPA",
"source_dataset": "eGRID",
"year": 2022,
"region": "US-NWPP",
"category": "Electricity",
"source_lca_activity": "electricity_generation",
"data_quality_flags": []
},
"constituent_gases": {
"co2e_total": 0.00125334421632,
"co2e_other": null,
"co2": 0.0012454134537600002,
"ch4": 1.14408e-7,
"n2o": 1.830528e-8
},
"activity_data": {
"activity_value": 0.00457632,
"activity_unit": "kWh"
},
"audit_trail": "enabled"
}

Storage Example 2: Using S3

Let's take a slightly harder example, where we try to calculate emissions based on the use of S3 to store files.

This is harder for several reasons:

  • Hardware: Amazon has never published which sort of physical storage they use in S3, but it's generally safe to assume that cheaper HDDs are primarily used so we'll use the HDD emission factor.
  • Pre-allocation: Unlike certain services, S3 doesn't require pre-allocation of storage. You pay for what you store. It's likely that you share hard-drives with other consumers so we only consider the amount of storage actually used.
  • Replication: S3 data is replicated in 3 different locations, meaning we'll need to take the amount we've stored and multiply it by 3.

For instance, if we're storing 5GB in S3, we'd use the HDD emission factor and an amount of "15GB". The latter is because the data is replicated three times, effectively using 15GB of storage. The resulting CO2e emissions for storing this data for a week are calculated below.

Request
curl --request POST \
--url https://beta4.api.climatiq.io/compute/aws/storage \
--header 'Authorization: Bearer API_KEY' \
--data '{
"region": "us_west_2",
"data": 15,
"data_unit": "GB",
"storage_type": "hdd",
"duration": 7,
"duration_unit": "day"
}'
Response
{
"co2e": 0.0005091710878800001,
"co2e_unit": "kg",
"co2e_calculation_method": "ar4",
"co2e_calculation_origin": "source",
"emission_factor": {
"name": "Electricity supplied from grid",
"activity_id": "electricity-supply_grid-source_supplier_mix",
"id": "7518e461-7980-47ab-89f1-5f126dde33a9",
"access_type": "public",
"source": "EPA",
"source_dataset": "eGRID",
"year": 2022,
"region": "US-NWPP",
"category": "Electricity",
"source_lca_activity": "electricity_generation",
"data_quality_flags": []
},
"constituent_gases": {
"co2e_total": 0.0005091710878800001,
"co2e_other": null,
"co2": 0.0005059492155900002,
"ch4": 4.647825000000001e-8,
"n2o": 7.436520000000001e-9
},
"activity_data": {
"activity_value": 0.0018591300000000003,
"activity_unit": "kWh"
},
"audit_trail": "enabled"
}
Underlying methodology

Climatiq relies on the Cloud Carbon Footprint (opens in a new tab) methodology for most of our assumptions such as the power-usage of memory and vCPU's. While the CCF methodology allows for specific power calculations based on the underlying hardware, Climatiq currently only uses an average watts per vCPU per provider, and not architecture specific power consumption data.

Summary

This guide provides a solid foundation on how to calculate the carbon emissions of your cloud computing usage. While Climatiq's emission factors are comprehensive for many aspects of cloud computing, it doesn't cover areas such as network traffic to the end-user, or network traffic between your servers.

For a more accurate and complex assessment, don't hesitate to get in touch (opens in a new tab). Together, we can make your cloud computing greener and more sustainable.