When we think about tackling climate change, we might picture renewable energy, electric vehicles, or planting trees. However, we rarely consider the impact of the software and digital services we use day-to-day.
The reality is that the software technology that powers the internet, mobile applications, and cloud services in general is a major consumer of energy and therefore produces massive carbon emissions.
Sustainable and green software engineering is a new way of working that forces developers to reconsider how the software is created, developed, and operated to conserve energy and improve its environmental impact. But what does this actually look like? How can better coding help save the world?
The Environmental Impact of Software
First, consider that data processing centres alone consume about 1% of the world’s electricity. The internet’s total footprint is comparable to that of the airline industry. The energy consumed comes from servers that are running code as well as cooling systems that must release the heat generated by the hardware and the network infrastructure that moves data across the globe.
Take, for example, every time you want to view a high-definition video, your device communicates with a data centre that must decode, process, and transmit that video transmitted. Using energy at every step. Load that by millions of users viewing simultaneously, whether it be Netflix or YouTube, and you can quickly see the numbers add up.
Writing Efficient Code: A Practical Example
Developers can decrease energy consumption by writing more efficient code, and there is a practical example shown here. Consider the example of a weather app that checks a remote server every couple of seconds for updates to the prediction. If the app pulls new data each time a vote is performed, and the app was designed badly so that it pulls new data even when the user is not looking at the app, the server is doing unnecessary work for no reason whatsoever, and the user is using energy unnecessarily by asking the server.
An app designed to pull new data from a server only when the user interacts with the app, by opening the app or manually refreshing, has significantly decreased the amount of server surveys and reduced the energy footprint overall. Again, this may not seem significant. However, if all users used the more efficient version of the app, all that energy savings would be combined.
Greener Cloud Use: The Role of Time and Place
Another important factor is where and when workloads run. Workloads executed in different cloud data centres can have different carbon footprints based on the way the energy they consume is generated. For instance, Google Cloud’s datacentre in Finland is nearly 100% renewable energy, while others may rely on fossil fuels.
Consider the following example: A company pushes back non-time-sensitive data processing jobs to run “at night” in a low-carbon data centre, where the company reduced the carbon impact without impacting performance. By pushing workloads to times and places where their energy requirements can be met cleaner and more frequently, they significantly reduced the carbon impact. Specifically, they were conducting what is now being referred to as “carbon-aware computing”, a concept that is gaining interest amongst cloud users.
Decreasing Data Transferring: The Why?
The network infrastructure of the internet uses a significant amount of energy. Energy is flowing across the globe for every bit of data we transfer, whether across routers, switches, or undersea data cables.
Web developers can assist by minimising the final size of assets, such as images, videos, and scripts. For example, Instagram uses highly efficient image compression algorithms that change the file size without sacrificing quality, using less energy when loading a photo on both the device and on the server.
Another way to reduce unnecessary disposal of data, and thus energy, is through lazy loading: images and content are only loaded as necessary (example: scroll down the secure page to see the images).
Case Study: How Spotify Made Streaming Greener
Spotify, a leading music streaming company, has taken steps to promote the sustainability of its service by improving the data used and infrastructure of its service. One way to improve data and sustainability is to change the speeds at which music is delivered based on user context. When a user is on a mobile network or encrypted reduce the speed of the stream to create less data, help user energy consumption, and maintain audio playback quality.
This adaptation decreases the amount of data to be processed and transmitted, improving downstream energy consumption for both the user and server. Spotify has demonstrated that sustainability efforts can support user experience satisfaction.
Tools to Measure and Improve Software Sustainability
A key first step in taking action on the environmental impact of software is understanding it. Teams can use tools like Cloud Carbon Footprint to help measure, in real time, the carbon emissions from their cloud activity, to identify points of interest (hotspots) and find ways to optimise.
In a similar way, developers can use profiling tools that can show them the energy usage from their applications. For instance, Android Studio provides an Energy Profiler that breaks down how much power the different elements of a mobile app use, allowing developers to isolate the elements that are using too much power.
Every saved unit of energy, every optimised unit of data, and every avoided request to a server will take a toll, so the next time you write some code or design a system, consider asking, “What can I do to make this as green as possible?”, you may just help change the world.