DEV Community

Cover image for Monitor the environmental impact of your EC2 instances with Cloud Scanner by Boavizta
jdxlabs
jdxlabs

Posted on • Updated on

Monitor the environmental impact of your EC2 instances with Cloud Scanner by Boavizta

Nowadays, we can't ignore that our way of life continually creates a debt towards the environment, that's why the industry is more and more interested in the subject of Green IT and I was led to work on it via the Responsible Digital Circle, in my company SFEIR.

The digital environmental context

According to studies, digital technology is responsible for 4% of global greenhouse gas emissions, and the sharp increase in uses suggests a doubling of this share by 2025 (1).

At first sight, I thought that it could be easy to act to reduce this debt, that it was just a matter of time that we gave it, but entering the subject, I realized a bit more the complexity behind it. I took my first environmental slap and it's a good point because it encourages me to have a much more realistic approach (and I don’t even talk about greenwashing tendencies).

There are different angles of attack we can focus on, without being exhaustive :

  • Increase sustainability of materials, because production cost is heavy, and we can't rollback, when it's produced, it's too late.
  • The greenhouse gas emissions and electricity consumption are the things we most commonly focus on, but there are other criteria in the chain of production that have a significant impact (like water consumption, mineral extraction, etc.).
  • Care about the different production methods for our materials, because it really depends on the methods behind it, following the political choices of countries (for instance, in France, gas emissions for electricity are low, with the strong choice for nuclear power).
  • We can differentiate methodologies for servers and devices (laptops, smartphones, computers, screens), usually devices have a bigger production cost, and for servers, it is more relevant to focus on power consumption (but it also depends on how materials are created, the balance may tip the other way)
  • We can determine different scopes for the gas emissions (2)
  • It is more than relevant to look at the impact of data centers in general and the cloud in particular. Even the latest measurements provided by Amazon recognize that it represents 71.54 million tons of CO2 per year, in the world, constantly increasing over the years, despite the desire to move towards zero emissions. (3)
  • We can also act on the development itself, and the UX/UI eco-conception (Are all the features useful ? Are they inexpensive in resources ?) (4)
  • There is work to do also about recycling solutions and giving products a second life.
  • In the near future, we can imagine that governments set clear guidelines to follow to limit the environmental impacts, and maybe penalties, but for now we have to count on the initiative of people in companies and voluntary associations. Digital is just a part of the movement, which can therefore be seen from an overall improvement perspective.

Monitor environmental impact in the cloud

As a Cloud Engineer, I wanted a solution to estimate the carbon footprint of my resources on the Cloud. To start, I was interested in AWS which is the provider I know best.

In the cloud, we don’t have access to lower layers of the machines, so we can't rely on low level probes to measure power consumption.

We just naturally know that the fewer resources we use, the less we consume, but precise metrics will help you to have a global vision and to be more relevant.

AWS has recently offered a calculator, the Customer Carbon Footprint Tool to assess the environmental impact, which gives a MTCO2EQ measure for EC2, S3 and other managed services, by geography (APAC, AMER, EMEA).

AWS carbon footprint

This is an interesting tool, still a work in progress, but my attention fell on another tool, focused on EC2 instances and providing more specific metrics so far than the tool provided by Amazon.

Monitor environmental impact with Cloud Scanner

Boavizta is an association that provides commons and open source tools to help us in our approach to limit the digital environmental impact.

Among these commons, Boavizta provides Cloud Scanner, a solution to monitor the environmental impact of EC2 instances.

As we do not have access to the lower layers of the machines, Boavizta has implemented methodologies to estimate data which has resulted in an API to assess the environmental impact : Boavizta API.

The API is based to follow the Life Cycle Assessment (LCA) which includes all stages of product energy consumption and not just usage. (5)

We can for instance evaluate the consumption of a t3.micro instance :

curl -X 'POST' \
'https://api.boavizta.org/v1/cloud/aws?instance_type=t3.micro&verbose=false&allocation=TOTAL' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "hours_use_time": 2,
  "usage_location": "FRA"
  }' | jq
{
  "gwp": {
    "manufacture": 38,
    "use": 0.003,
    "unit": "kgCO2eq"
  },
  "pe": {
    "manufacture": 490,
    "use": 0.3,
    "unit": "MJ"
  },
  "adp": {
    "manufacture": 0.0036,
    "use": 1e-09,
    "unit": "kgSbeq"
  }
}
Enter fullscreen mode Exit fullscreen mode

GWP (Global Warming Potential) refers to the global warming potential of a gas emitted into the atmosphere (measured in kgCO2eq : Kilogram of Carbon dioxide Equivalent).

PE (Primary Energy Use) refers to energy in its raw form, before it has been converted by humans into other forms of energy like electricity, heat or transport fuels (measured in MJ : MegaJoule).

ADP (Abiotic Resource Depletion, mineral & metal) is one of the most commonly deliberate classes of impact on abiotic resources, which are non-living natural substances, such as copper ore and crude oil, and may contain energy resources, such as wind power (measured in kgSbeq : Kilogram Antimony(symbol: Sb) Equivalent).

As explained in the documentation, data is collected by Boavizta manually or with scrappers referring to the manufactures declarations.

An endpoint is available to try the API : "api.boavizta.org", but you have to host it on your own server, it can be easily done with the serverless framework.

# Install the serverless framework and plugins
npm install -g serverless
npm i

# Authenticate
export AWS_PROFILE=your-own-profile

# Deploy
serverless deploy

Enter fullscreen mode Exit fullscreen mode

CloudScanner uses the Boavizta API, and simplifies the use of this API by providing a turnkey solution, combining it with real-time usage data from your current AWS account, to provide a holistic view of the impacts of your EC2 instances by regions.

Let's try Cloud Scanner

If you already have running instances on your AWS account, you can quickly try the solution like this :

export AWS_PROFILE=your-own-profile

git clone git@github.com:Boavizta/cloud-scanner.git
cd cloud-scanner

docker-compose up
Enter fullscreen mode Exit fullscreen mode

For a proper installation, you can install it with serverless, following this design :

Cloud Scanner AWS Serverless Design

You should now have access to the Grafana UI here : http://localhost:3001.

Then you will find the dashboard in Browse Dashboards > General > Environmental impacts of cloud :

Cloud Scanner Grafana Dashboard

Let's read the metrics

For demonstration purpose, I created three t3-micro instances, that can be compared :

  • one in France (eu-west-3)
  • one in Ireland (eu-west-1)
  • one in Germany (eu-central-1)

So we have three instances assessed, all these regions are covered by the tool, and we retrieve our indicators published by the Boavizta API : PE, GWP and ADP.

We can differentiate two different scopes :

  • Manufacture (displayed here for the entire server lifecyle, not amortized)
  • Use (displayed here for one hour of use)

About the Manufacture scope, we can see the three regions have equivalent consumption, according to the indicators.

About the Use scope, we can see consumptions are différent between the three regions.

Primary energy use is more expensive in Germany (0.0800 MJ) than in Ireland and France, where they are equivalent (0.0500 MJ).

GWP use is more expensive in Germany and Ireland (0.00200 kgco2eq) than in France (0.000500 kgco2eq).

ADP use is more expensive in Germany (4e-10 kgSbEq), followed by France (2e-10 kgSbEq), then Ireland (1e-10 kgSbEq).

What we can deduce is that the environmental impacts are different between these three regions, Germany being the most expensive in terms of energy according to these indicators, where France is more interesting for GWP and Ireland for ADP.

In addition, it is possible to view this data and export it in CSV or PNG format, via the Datavizta tool which is provided, to integrate this data as part of a larger study that you would like to undertake.

Conclusion

With Cloud Scanner, you have specific and relevant data about energy use of your EC2 instances on AWS, you can implement it in your global approach to limit digital environmental impact.

It's an open source product, feel free to use it and maybe even participate, the creators are actively working on evolutions and constantly searching for contributors.

In the end, I would say that metrics are important to give you levers for action, the more relevant they are, the better. But they should not constitute an obstacle to adopting a certain form of global sobriety in the way of designing projects, thinking about their purpose and extending the life of the equipment.

Sources :

(1) The Shift Project - Climate crisis: The Unsustainable Use of Online Video - 2019

(2) Boavizta - Digital & environment : How to evaluate server manufacturing footprint, beyond greenhouse gas emissions - 2021

(3) Amazon - Sustainability - Our Carbon Footprint - 2021

(4) [FR] Collectif Conception Numérique Responsable - 115 Web Ecodesign Best Practices

(5) Wikipedia - Life-cycle assessment

Top comments (0)