Today I want to see something different of what I have been doing.
Some of you may know that Thoughtworks regularly releases their Technology Radar. According to Thoughtworks:
The Radar is a document that sets out the changes that we think are currently interesting in software development — things in motion that we think you should pay attention to and consider using in your projects. It reflects the idiosyncratic opinion of a bunch of senior technologists and is based on our day-to-day work and experiences. While we think this is interesting, it shouldn’t be taken as a deep market analysis.
The radar basically suggest what techniques, tools, platforms, languages and frameworks one might want to adopt, try, assess or hold implementing in our projects.
I usually take a look at the radar every time it comes out, bookmark whatever calls my attention and then when I have time I can go more into detail.
That is where I found the Carbon Aware SDK
and also recently I got a certification from the Linux foundation on Green Software, so it was like it called to me.
If you want to reduce your software carbon footprint there are only a few ways to do it. And the obvious way is to use cleaner energy.
You can reduce the carbon footprint of your application by just running things at different times and in different locations. That is because not all electricity is produced in the same way. Most is produced through burning fossil fuels, some is produced using cleaner sources like wind and solar.
The Carbon Aware SDK helps you build the carbon aware software solutions with the intelligence to use the greenest energy sources. Run them at the greenest time, or in the greenest locations, or both! Capture consistent telemetry and report on your emissions reduction and make informed decisions.
The Carbon Aware SDK has a WebApi and a Command Line Interfave (CLI)
The WebApi is the preferred deployment within large organisations to centralise management and increase control and auditability, especially in regulated environments. It can be deployed as a container for easy management, and can be deployed alongside an application within a cluster or separately.
The CLI tends to be handy for legacy integration and non-cloud deployments, where a command-line can be used. This tends to be common with legacy DevOps pipelines to drive deployment for integration testing where you can test your deployment in the greenest location.
The Carbon Aware SDK is a project part of the Green Software Foundation (GSF) and the GSF Open Source Working Group. And here you can see the contribution guide
I will try to run the Web API. So first we have to have the prerequisites.
- Docker Desktop/CLI ( instructions for windows or mac)
- VSCode (it is recommended to work in a Dev Container and more explanations here)
- Remote Containers extension for VSCode: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers
Now we have to follow this steps to get the Web API running
- Set up the repository
git clone https://github.com/Green-Software-Foundation/carbon-aware-sdk.git
- Change directory
cd carbon-aware-sdk
- Open VSCode
code .
- Open VSCode Command Palette
cmd + shift + P
- Run the command
Dev Containers: Open Folder in Container
and select the current folder. You should see that the Dev Container is starting - Change directory to
cd src/CarbonAware.WebApi/src
- Run the application
dotnet run
Here is going to depend on your configuration
The SDK supports multiple data sources for getting carbon data. At this time, only a JSON file, WattTime and ElectricityMaps are supported.
So I'm going to use the JSON file to get data and I'm going to get it from an example file /workspaces/carbon-aware-sdk/src/data/data-sources/mycustomfile.json
Now that I have my data source I can do a GET request and for this I like Postman and I'm going to use this to make the request http://localhost:5073/emissions/bylocations/best?location=westus&location=eastus&location=westus3&time=2022-08-23T00%3A00&toTime=2022-08-23T23%3A59
And there you have it, obviously you can play with it more now that it is working, but I'm telling you this is going to be asked by more and more industries/companies, they will want to know and show their CO2 consumption so that customers can prefer greener options, so having an open source options is really awesome.
That is it for now :-)
Cheers!
Top comments (0)