6 mins
You have 0 further articles remaining this month. Join LeadDev.com for free to read unlimited articles.

Carbon efficiency isn't enough. It's time our industry started creating applications that are carbon-aware.

I love Netflix comedy specials, especially Asian comedians; culturally it's a snap. One of my favorites is Ronny Chieng, and this sketch from his latest special had me in stitches.

Forget Amazon Prime, he wants Amazon Now, or even Amazon Before. When COVID-19 hit, there was no more Amazon Prime; there was barely Amazon ten days later.

What Amazon did was demand shaping. When a resource is constrained (deliveries), instead of continuing to demand the same (next-day delivery), they shape demand to match the supply (ten day delivery). You’ll see examples of demand shaping everywhere: everywhere except our applications. Our applications often demand the same, regardless of supply. If the database is slow, it doesn't matter: we make the same requests. If the user's internet is slow, it doesn't matter: a website requests the same images. This frequently results in poor user experience. The Amazon equivalent would be to always promise next-day delivery but consistently deliver ten+ days later.

Sustainable software engineering

As a sustainable software engineer, my primary goal is to build carbon-efficient applications. A carbon-efficient application is one that extracts the maximum value for each gram of carbon it is responsible for emitting into the atmosphere.

Sustainable software engineering is an emerging discipline at the intersection of climate science, software, hardware, energy markets, and data center design.

There are eight principles of sustainable software engineering, and I encourage you to read them all on the website principles.green after you finish this article. To summarise the first three principles:

  • Reducing carbon emissions is the goal
  • Electricity is a proxy for carbon because most electricity is still created through the burning of fossil fuels
  • The electricity generated through burning a lot of fossil fuels is said to have a high-carbon intensity. The electricity that was generated through renewable or low-carbon means has a low-carbon intensity. The carbon intensity unit of measurement is gCO2eq/kWr or grams of carbon per kilowatt-hour.


Carbon-aware vs. carbon-efficient

Carbon efficiency can be transparent to the end user. You can be more efficient at every level in converting carbon to useful functionality while still keeping the user experience the same.

But at some point, being transparently more carbon-efficient isn't enough. If the carbon cost of running the application right now is too high, we can change the user experience to reduce carbon emissions further. At the point the user is aware the application is running differently, it becomes a carbon-aware application.

I'm not proposing that we shackle all our applications so they perform worse at all times. I'm suggesting that we start building applications that are able to adapt when the carbon cost of running them is high.

Demand shaping

To be carbon-aware is to implement what I think to be the secret door of an exceptionally creative world, and the seventh principle of sustainable software engineering: demand shaping

A great example of demand shaping is video conferencing software. When a resource “bandwidth" is scarce, it automatically changes the user experience. It reduces video quality while keeping the audio quality high. It shaped the demand (video quality) to match supply (bandwidth).

Demand shaping carbon-aware applications is all about the supply of carbon. When the carbon cost of running your application becomes high, shape the demand to match the supply of carbon. This can happen automatically, or the user can make a choice.

Onlign: a carbon-aware operating system

An example of what a carbon-aware application might look like is the carbon-aware operating system. Before you go away and try to install it, it's a design project by Lu Ye at the Royal College of Art, and it’s on display in their online exhibition. She has made a fantastic explanation video for it and I recommend you take a look at her visually stunning work to see the several unique and exciting features of the OS. The features I particularly loved were that during times it detected high-carbon intensity electricity, it would perform some demand shaping. For example, instead of watching a Netflix video, perhaps you want to listen to a podcast? Instead of making a video call, perhaps a low-carbon, touch-sensitive interface will do?

Hand on touch screen device

The ideas expressed in this project paint the picture of what a carbon-aware application might look like.

Eco-modes

Eco-modes are often used in life: my car has one, and my washing machine has one. When switched on, the performance changes as they consume fewer resources (gas/electricity) to perform the same task. It's not cost-free (otherwise, we would always choose eco-modes), so we make tradeoffs. Because it's a tradeoff, eco-modes are almost always presented to a user as a choice, and the user decides if they want to go with it and accept the compromises.

Software applications can also have eco-modes. 

At MozFest last year (2019) an eco-mode for Firefox was brainstormed. The following ideas are a selection of the ones that were discussed:

  • Save your data for future enjoyment. Plain text in the morning, Netflix at night.
  • Browser warning if browsing website is not on green energy.
  • Request skinny media by default.
  • Strip ads, images, videos. Minimal media.

The ideas they discussed broadly fall into the following two categories of demand shaping:

  1. Intelligence. Giving users information so they can make informed decisions.
  2. Automatic. The application makes decisions that reduce carbon emissions.

Will users accept application eco-modes?

There is evidence that just asking users to change behavior, works. Opower uses something called behavioural demand response. At times of high-energy demand, the carbon intensity shoots up because the only way to meet that demand is to burn lots of fossil fuels. Opower realized that simply asking users to not use energy at peak times, worked. 

What might demand shaping look like for a website?

There are many things you can do to build websites that are more carbon-efficient, such as more efficient code. Building websites that are carbon-aware is different, as it intends to change the user experience to improve carbon efficiency. Let's explore what that might look like for a website.

The principle of sustainable software engineering that websites often trigger is the sixth one: networking. Websites, by their nature, transmit lots of data across the web, and transporting data is a proxy for carbon; so reducing the amount of data and distance on the network that the website must travel across is an excellent way to be carbon efficient.

For example, we know that data transmitted over mobile networks (3G/4G) is 4-7 times more carbon-polluting than the same data transmitted over a WiFi network. Though we’re unsure of the exact numbers, we know that it's relatively worse to browse a website on mobile networks than on WiFi. 

Websites can detect whether they are on mobile networks. A demand shaping feature might be to automatically request skinny media (lower-quality images and videos) if the website is being browsed over cellular networks.

Alternatively, a website could simply suggest the user switches to an eco-mode whether they are on a mobile network or not, or only if they are on one. If switched on, the site will run more carbon efficiently but at the expense of user experience. 
If some of this makes you think, this would make the website run faster, then yes! Green carbon-efficient applications are almost always going to be cheaper, faster, and more resilient than their gray counterparts.

Summary

Carbon-aware applications are not afraid of using demand shaping to reduce carbon emissions at the expense of user experience.

It is rare that we can directly measure the carbon cost of our applications, but if we follow a resource chain down and it eventually has a link to carbon emissions, then that is a good proxy for carbon. Electricity is an excellent example of this, and so is the transportation of data across the internet.

Applications can either be carbon-aware by default, and automatically change the user experience, or they can have an eco-mode that the user toggles. The least heavy-handed approach is that when the application detects the carbon cost of running has increased, it nudges the user to engage the eco-mode. So consider adding an eco-mode to your application. If it's a feature toggle, only the users who opt-in will be impacted. 

And check out the principles of sustainable software engineering for ideas on how to make your application more carbon-efficient during eco-modes. Any resource that can be proxied back to carbon is constrained, and so we should always consider demand shaping to make more efficient use of those resources.