Reducing greenhouse gas (GHG) emissions is an urgent global priority. It has recently been underlined by commitments from both the political and business spheres. By 2050, the Biden administration has pledged a trillion dollars of clean-energy investments
and the EU has committed to becoming carbon-neutral by 2050. And Blackrock, the world’s largest money manager, which in 2020 pledged to put sustainability at the heart of its investment strategy, is just the most prominent of many investors and corporates
now pivoting to climate-friendly business models.
Yet, while emissions need to fall fast to meet global commitments, the power demands of information and communications technology (ICT) are moving in the opposite direction. Although it only accounts for 5–9% of electricity consumption today, it’s estimated
that by 2030, ICT could account for as much as 21% of global electricity demand. If all the energy it needed came from zero-carbon sources, this might not be a problem. But in 2019, only 11% of the world’s primary power came from renewable generation and this
will not change dramatically overnight. There is, therefore, a pressing need for technology to take an approach that reduces its demands for energy and resources, all the way from production to end use.
When assessing their GHG emissions, most companies focus on Scope 1 and 2, which cover direct emissions, for example, from burning fuel and indirect emissions from purchasing electricity. However, technology companies mostly have low GHG emissions in these
categories. It’s in Scope 3, value chain emissions, where the bulk of their environmental impact happens. This covers indirect emissions that arise, for example, from the use of their products. Of Microsoft’s expected 16 million metric tons of carbon emissions
in 2020, around 75% were in Scope 3.
Coding is typically about efficiency of effort. What if it could also extend to energy efficiency — and so become part of the climate change solution?
There is immense potential. Software with open-source code is likely to contain redundant sections that could waste network and CPU parsing time. The choice of image format and visual design has an impact on loading times and user journeys: scaled up to
thousands of users, poor choices can translate into days of extra operating time. Even decisions about how long information should be retained can impact on caching and efficiency.
Time for a change of mindset
At the moment, there’s little awareness of the potential for sustainable software development. This is driven, at least in part, by a conflict of interest between development and operating budgets. Making software more efficient costs time and money but
efficiency is essential to keep operating costs low. Managers want the efficiency: but to deliver it, developers need more time and resources.
What’s needed is a change of mindset. If sustainability and efficiency are the goals instead of initial cost, managers can focus instead on optimising software end-to-end, which will ultimately drive operating cost, energy efficiency and performance. Software
analysts, architects and engineers all need to engage with this new mindset because, ultimately, the efficiency of computers depends on the software they run. All code has a footprint and it should be as small as possible. The energy-saving potential is huge:
scaled up to servers worldwide, and beyond them to consumer devices, every line of code has the potential to reduce energy consumption and emissions.
The scope and potential of GreenCoding
GreenCoding, as we call it, is based on architectural principles and supported by three pillars: the logic, methodology and platforms used to write, develop and run the code.
The three pillars of GreenCoding
Sustainable software development starts with three overarching principles that should form the basis of all subsequent decisions.
1. Shut down when idle
Just as you would switch off the lights when there’s no one in a room, software should be shut down when no one is using it. This means designing applications according to modular principles so they can be shut down separately. Central to microservices and
serverless architecture, this approach covers scalability and stopping/starting replica modules due to demand fluctuations, as well as total shutdowns. Make sure code is always in a position to separate individual sections and transform them into new and autonomous
2. Avoid impulsive consumption
Is real-time processing necessary? If software includes asynchrony, jobs can be collated for clustering and processing together in sequence. If they are not checked to see whether they need processing in real time, all processing could be carried out in
real time by default, increasing energy consumption. Analysis could reveal that hourly or even end-of-day processing may be appropriate. You can apply the same approach to the landing page of a web application that has inner sections based on dynamic content
but initial landing content that changes only daily. Here, you could use static site generation techniques to rebuild the page per release, per week, day or even hour, transforming dynamic content into static content that is much easier to optimise in terms
of energy consumption.
3. Focus your time and energy investment
This third principle of greener architecture looks at the overall lifecycle of software: its creation, use, maintenance and disposal. Seeing the big picture means starting with the software’s target audience. What is it? Humans or other machines? How many
users will there be — dozens or thousands? Drilling into the detail here will help you understand usage frequencies and the duration of average interactions. Use this analysis to identify which architectural elements will need most energy, and, therefore,
where you need to invest time and effort. For example, in an application that generates thousands of images every hour, saving even 0.1 of a second to load an image could save significant energy over time.
GreenCoding is in its infancy. Yet, we have seen that it aligns well with the iterative cycles and data-driven methodology of Agile development. And it can be integrated into every part of the Continuous Integration/Continuous Delivery process, transforming
how software is delivered. It can be time-intensive. However, this should be balanced against its benefits, which go beyond energy efficiency to include better usability and user experience, and reduced operating costs.
GreenCoding is a new frontier for software development and will ultimately shape how all software will be made — for the greater good. The keys to sustainable software are at our fingertips.