Docs
Guides
GuidesHow to Calculate Cloud Carbon Footprint

How to Calculate Cloud Carbon Footprint

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

Subscription Plan Required: This feature is only available as an add-on to our Developer or Enterprise plans.

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 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 EarthEmission can help you calculate 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, EarthEmission 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.EarthEmission.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.03973,
    "total_co2e_unit": "kg",
    "memory_estimate": {
        "co2e": 0.00166,
        "co2e_unit": "kg",
        "co2e_calculation_method": "ar6",
        "co2e_calculation_origin": "earthemission",
        "emission_factor": {
            "name": "Electricity supplied from grid",
            "activity_id": "electricity-supply_grid-source_supplier_mix",
            "id": "3f539790-921e-49fc-99d1-6fe4d29c71c4",
            "access_type": "public",
            "source": "EPA",
            "source_dataset": "eGRID",
            "year": 2023,
            "region": "US-NWPP",
            "category": "Electricity",
            "source_lca_activity": "electricity_generation",
            "data_quality_flags": []
        },
        "constituent_gases": {
            "co2e_total": null,
            "co2e_other": null,
            "co2": 0.00165,
            "ch4": 1.508e-7,
            "n2o": 2.081e-8
        },
        "activity_data": {
            "activity_value": 0.005733,
            "activity_unit": "kWh"
        },
        "audit_trail": "enabled"
    },
    "cpu_estimate": {
        "co2e": 0.01673,
        "co2e_unit": "kg",
        "co2e_calculation_method": "ar6",
        "co2e_calculation_origin": "earthemission",
        "emission_factor": {
            "name": "Electricity supplied from grid",
            "activity_id": "electricity-supply_grid-source_supplier_mix",
            "id": "3f539790-921e-49fc-99d1-6fe4d29c71c4",
            "access_type": "public",
            "source": "EPA",
            "source_dataset": "eGRID",
            "year": 2023,
            "region": "US-NWPP",
            "category": "Electricity",
            "source_lca_activity": "electricity_generation",
            "data_quality_flags": []
        },
        "constituent_gases": {
            "co2e_total": null,
            "co2e_other": null,
            "co2": 0.01662,
            "ch4": 0.000001519,
            "n2o": 2.096e-7
        },
        "activity_data": {
            "activity_value": 0.05775,
            "activity_unit": "kWh"
        },
        "audit_trail": "enabled"
    },
    "embodied_cpu_estimate": {
        "co2e": 0.02135,
        "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.02135,
            "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, several aspects need to be taken into account, including:

  • The particular mix of energy provided by the source.
  • Whether the factor includes upstream emissions.
  • Whether it includes transmission and distribution losses.

This information is encoded in the activity_id and the source_lca_activity fields provided in the 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, earthemission 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 or your cloud provider's documentation.

Let's take a couple of examples of how we can use the earthemission 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:

  • Function runtime: 200ms
  • CPU usage: 1 vCPU core
  • Location: US West (Oregon) (see this link for a detailed guide of AWS regions)

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

Request:

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

Response

{
    "co2e": 1.283e-8,
    "co2e_unit": "kg",
    "co2e_calculation_method": "ar6",
    "co2e_calculation_origin": "earthemission",
    "emission_factor": {
        "name": "Electricity supplied from grid",
        "activity_id": "electricity-supply_grid-source_supplier_mix",
        "id": "3f539790-921e-49fc-99d1-6fe4d29c71c4",
        "access_type": "public",
        "source": "EPA",
        "source_dataset": "eGRID",
        "year": 2023,
        "region": "US-NWPP",
        "category": "Electricity",
        "source_lca_activity": "electricity_generation",
        "data_quality_flags": []
    },
    "constituent_gases": {
        "co2e_total": null,
        "co2e_other": null,
        "co2": 1.275e-8,
        "ch4": 1.165e-12,
        "n2o": 1.608e-13
    },
    "activity_data": {
        "activity_value": 4.429e-8,
        "activity_unit": "kWh"
    },
    "audit_trail": "enabled"
}

Combining the CPU and memory usage for a serverless function will 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:

  • The type of hardware backing your storage: HDDs generally consume less power but are slower than SSDs.
  • Calculate emissions based on storage purchased, not just used. Even if you're not using the storage, having it available will use electricity.
  • 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 replication factors, which covers many services for all the major cloud providers.

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, the EC2 Instance Storage is not replicated. This means we only have an estimate with the data we've purchased.

Request

curl --request POST \
    --url https://beta4.api.earthemission.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.001325,
    "co2e_unit": "kg",
    "co2e_calculation_method": "ar6",
    "co2e_calculation_origin": "earthemission",
    "emission_factor": {
        "name": "Electricity supplied from grid",
        "activity_id": "electricity-supply_grid-source_supplier_mix",
        "id": "3f539790-921e-49fc-99d1-6fe4d29c71c4",
        "access_type": "public",
        "source": "EPA",
        "source_dataset": "eGRID",
        "year": 2023,
        "region": "US-NWPP",
        "category": "Electricity",
        "source_lca_activity": "electricity_generation",
        "data_quality_flags": []
    },
    "constituent_gases": {
        "co2e_total": null,
        "co2e_other": null,
        "co2": 0.001317,
        "ch4": 1.204e-7,
        "n2o": 1.661e-8
    },
    "activity_data": {
        "activity_value": 0.004576,
        "activity_unit": "kWh"
    },
    "audit_trail": "enabled"
}

Underlying methodology earthemission relies on the Cloud Carbon Footprint 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, earthemission 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 earthemission'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. Together, we can make your cloud computing greener and more sustainable.

Was this helpful?
Docs
Copyright © earthemission.com. All rights reserved.