Green Software - How develop a green or sustainable software?
The title is a question not answered currently. I know... it is a spoiler but not to make you give up to read the theme but to understand it is a vast and important area that should be investigate.
It is an important concern in the current day. The planet is yelling to help and we, as professionals, must pay attention to the carbon pollution of the application we build: The tech’s carbon footprint. If it is not enough to convince you about its importance, consider it as an impact on the company's cost.
Most part of actions to achieve the sustainable goals by the company are in the green cloud to reduce the cost of the data centers, big responsible for the energy consumption. They are becoming bigger very fast and have a perspective to increate the consumption by between 8% and 20% by 2030. This brings up some initiatives to deal with these growths. Europe Green deal is an example to enforce the target where data centers should be climate neutral, energy-efficient, and sustainable by 2030.
However, there is another part that has to be explored. That is in the software development direction: how to create the code, measure the energy efficiency of the code, or test it. You can see tools to measure the energy consumption of software, but regarding the development not so much. Many of these tools are hard to config or are to a specific architecture.
Principles
Here are some principles we have to have in our mind during our work in the direction to have green software:
- General Principles (2019)
- 1. Carbon: Build applications that are carbon efficient.
- 2. Electricity: Build applications that are energy efficient.
- 3. Carbon Intensity: Consume electricity with the lowest carbon intensity.
- 4. Embodied Carbon: Build applications that are hardware efficient.
- 5. Energy Proportionality: Maximize the energy efficiency of hardware.
- 6. Networking: Reduce the amount of data and distance it must travel across the network.
- 7. Demand Shaping: Build carbon-aware applications.
- 8. Measurement & Optimization: Focus on step-by-step optimizations that increase the overall carbon efficiency.
- Updated Principles (2022)
There are patterns that can be used to apply those principles. More about the patterns you can see in Green Software Patterns.
Green Software Foundation (GSF)
Green software is software that is responsible for emitting fewer greenhouse gases. Our focus is reduction, not neutralisation.
The foundation aims to help the software industry contribute to the information and communications technology sector’s broader targets for reducing greenhouse gas emissions by 45% by 2030, in line with the Paris Climate Agreement.
The foundation was lauched by Accenture, GitHub, Microsoft and Thoughtworks. It has as mission: Build a trusted ecosystem of people, standards, tooling and best practices for creating and building green software.
The GSF has some projects in that direction. One of them is the Software Carbon Intensity (SCI) Specification. The idea is to describe a methodology for calculating the rate of carbon emissions for a software system. It is more specific to software than GHG protocol which is a more generic industry measure. Here is a project that provides advice on how to quantify the emissions.
(*)Course: Green Software for Practitioners (LFC131).
Actions in data centers
The main initiatives are around the data centers, or to reduce the consumption or reuse the energy. Most of them are commitments to climate goals.
Microsoft's commitments [1] [2] exists since 2012. Examples of work in this direction are tools to help the customers to calculate their consumption and the pilot of a generator that runs on hydrogen fuel cells [3]. Also start a partnership with Accenture, GitHub and Thoughtworks to the creation of the Green Software Foundation [4].
The Amazon also added sustainability to the well-architecture pillar[5][6][7][8] where it is a shared responsibility between AWS and the customers. The AWS has a tool[9][10] to customers measure their carbon footprint. The goal is the carbon minimization by 2030.
The same way, Google has a commitment to reduce the consumption by 2030. One example of action done by the company is the use of renewable energy sourcing.
(+)Greenhouse Gas protocol - Greenhouse gas accounting standard.
(++)United Nations Framework Convention on Climate (UNFCCC)
(+++) power usage effectiveness metric
(++++)Is your website hosted green? Check here
Actions as a developer
As developers, some of the actions may seem distant from our day work. However, part of the action is directly related to our day-by-day. We have to be aware of the Principles that can follow us in our projects.
- Focus on and control features with higher power consumption and common usage scenarios
- Reduce data usage. Adopt efficient cache policy, minimize data exchange, and manage the lifecycle of stored data
- Remove or refactor unused features
- Detect and remove loops which can’t achieve their intended purpose and uselessly consume energy
- Adapt your app’s behavior according to the device power mode or other operating conditions
- Limit computational accuracy of the application to the desired level which commensurate with the operational needs
- Monitor real-time energy consumption of the application
- Language: Even the choice of programming language you use can influence the energy efficiency of the software
- Software Development: During development monitor real-time power consumption through techniques such as dynamic code analysis
In terms of programming languages the concerns are on the speed and energy efficiency as C, C++ and Rust in opposite of Ruby and Phython. Java is in the middle of the way. So the choose of the language can contribute to the green SW.
Here [12][13] you can see an investigation comparing the consumption of energy by programming language. In terms of energy and time 'C' was the best one and Java is in the fifth position. Perl, Python and Ruby are at the end of the line. JavaScript and TypeScript are in the middle of the table still losing to Java. The results from this work are: (1) a faster language is not always the most energy efficient, (2) Compiled languages tend to be the most energy-efficient and fastest-running than virtual machine and interpreted languages, even though manipulating strings with regular expression was most energy-efficient with interpreted languages, (3) Object-Oriented paradigm is more efficient than Functional paradigm.
In the same direction, as discussed in this podcast, the patterns used in the programming also can impact. The decorator pattern, for instance, is energy inefficient and intensive. The opposite of the flyweight that are energy efficient. The compiler can influence as well because of the structural optimization it can be done. However, it is not so effective because the hardware also can impact. In the same way, spaghetti Code can impact the consume of energy.
Most parts of the works that do not focus on data centers are within the academic scope. This work, (Energy Efficient Design Patterns), did a study comparing th energy consumption of three patterns: Template Method, State and Strategy. The tests was done in Java and the results show that there are significant differences between the energy consumption of design patterns and their non-pattern alternatives. Others interesting study about the patterns are: Evaluating the Impact of Design Pattern Usage on Energy Consumption of Applications for Mobile Platform, Energy Aware Software-Engineering and Developmen, Optimising Energy Consumption of Design Patterns, Energy Consumption Analysis of Design Patterns.
Thinking further the programming activities, the action also can might be surround that. The start point can be the choice of the computer. The MAC, for instance, is committed with the carbon neutral.
Some tools also can help the developers to be attentive to those achievements guiding them to reduce the algorithmic complexity. Example of tools are AWS Code Guru and Codacy.
Tools and Projects
- Cloud Carbon Footprint: a tool to monitoring the consume of energy in different aspects and giving some direction to improve different areas. It use the Cloud Carbon Coefficients to estimate the energy and carbon emissions.
- Carbon Aware SDK: An SDK to enable the creation of carbon aware applications, applications that do more when the electricity comes from clean low-carbon sources and less when it does not.
- Electricity Maps: used to understand the climate impact of global electricity use.
- Global Forest Watch: Global Forest Watch offers the latest data, technology and tools that empower people everywhere to better protect forests.
- CO2.js: JavaScript library that allows developers to estimate the emissions associated with their apps, websites and software.
- Carbone JS API: open source document generator
- EcoAndroid: IntelliJ plugin for android aplication
For more projects, here is a list of open technology projects. Also, you can find a list of repository regarding with climate change.
Videos
Conclusion
To apply the green actions is a challenge. It requires a change of mindset, best practices, models and tools to measure and reduce the effect of software on the energy consumption.
Reference
- Thoughtworks
- GSF
- Courses
- Reducing emmisions
- Science Based Targets Initiative
- FOUNDATIONS FOR SCIENCE-BASED NET-ZERO TARGET SETTING IN THE CORPORATE SECTOR
- What is a value chain? Definitions and characteristics
- What is a Carbon Offset?
- What is the difference between carbon removal and avoidance projects?
- PAS 2060 The ideal standard for carbon neutrality
- Commitments
- Global Warming vs Climate Change
- COP (Conference of the Parties)
- IPCC - The Intergovernmental Panel on Climate Change
- Electricity production by source, World
- Power Purchase Agreements (PPAs) and Energy Purchase Agreements (EPAs)
- 24/7 Hourly Matching of Electricity
- Google: Operating on 24/7 Carbon-Free Energy by 2030.
- Microsoft: Made to measure: Sustainability commitment progress and updates.
- The Paris Agreement
- Google Carbon Aware Data Centers: We now do more computing where there’s cleaner energy
- Microsoft Carbon Aware Windows: This Windows 11 update is trying to save the world
- Cambridge Institute for Sustainability Leadership
- Science-Based Targets Initiative (SBTi)
- Sustainable Architecture, AWS, & the Enterprise - Our Whitepaper
- WTF Does Tech Have to Do With the Planet?
- Software development methodology in a Green IT environment
- Green and Sustainability in Software Development Lifecycle Process
- Energy Efficiency across Programming Languages
- How much carbon CO2 emissions come from your application or choice of programming language?
- Carbon proxies: Measuring the greenness of your application
- Carbon-Aware vs. Carbon-Efficient Applications