What are Demand Shifting and Shaping in Green Software?
If you’ve ever looked at the Maturity Matrix produced by the Green Software Foundation (GSF), or spent time thinking about green software more broadly, you’ve probably come across the terms ‘Demand Shifting’ and ‘Demand Shaping’.
These terms have very similar meanings and are sometimes used interchangeably, but they are in fact two distinct concepts.
Demand shifting involves moving computation to regions, or times, when the carbon intensity is lowest. Demand shaping is about changing the way our system behaves, based on the carbon intensity of the electricity supply.
Let’s consider why we might want to do this.
In my talk, ‘Writing Greener Software Even When You Are Stuck On-Prem’, I make the point that with software carbon intensity, different places have different energy mixes. You can see this reflected in the GSF’s Software Carbon Intensity equation, which includes a location component. Moving to carbon-free electricity sources is a slow process and, inevitably, different locations will get there at different stages.
In addition, carbon intensity changes over time. Typically, electricity is produced so that supply always meets demand. Electricity storage is difficult, and since it has been largely unnecessary, there is currently little storage or other buffering in electricity grid systems.
This is a problem for renewables because their energy sources are less predictable than fossil fuels. When it’s cloudy or the wind isn’t blowing, carbon intensity increases because more of the electricity in your mix has to come from fossil fuels. When demand spikes, it is relatively easy to cope with it by turning to a fossil fuel source; you simply burn more coal and produce more electricity. Renewables lack this flexibility. So in times of peak demand, you typically have to fall back on fossil fuels for part of the electricity mix. Or you need to have enough wind turbines and solar panels to deal with peak demand, then throw away much of that power because most of the time you don’t need it, which garners you unfavourable headlines in the rightwing press.
This dispatchability problem is one of the reasons why nuclear power, another carbon-free source, could be a necessary if controversial part of the energy mix for the foreseeable future. (The other has to do with energy density; essentially we need more landmass to meet all our electricity needs from renewables).
Eventually we’ll have 100% carbon-free electricity everywhere but in the meantime, if we want to use fewer fossil fuels we’ll need to take proactive steps to do so.
For a really quick, easy win—particularly if you are running workloads on a public cloud—you can choose the region with the greenest electricity mix.
Electricity Maps is a tool that outlines this information. They’ve partnered with Google, AWS and Salesforce to provide customers with real-time, global coverage of the carbon intensity of electricity. If you are thinking about building a new on-prem data centre, it is probably the first thing you should look at.
We can go further though.
Demand Shifting
There are APIs available to help you look at carbon intensity, including WattTime, the GSF’s Carbon-Aware SDK and, in the UK, the Carbon Intensity API. Armed with these, you can apply a more advanced technique called demand shifting—responding to changes in carbon intensity by increasing or decreasing your demand.
Demand shifting can be done in one of two ways—based either on time or location. Time is probably easier and is likely more familiar. If you’ve ever had batch jobs that run overnight, you are thinking along the right lines.
Batching is one approach we can use, but since microservices became fashionable, we have all built distributed systems whether we needed to or not. Fortunately we have several other tools in our toolbox which were developed to get more resilience in distributed computing and can equally be applied in a carbon-aware way.
One is where we either don’t show something if a microservice doesn’t respond in time, or we show slightly stale results retrieved from a cache if we have a suitable one available.
The technique is called Graceful Degradation.
Netflix famously used it a lot, particularly in their early days before they discovered the magic of FIT/Chaos engineering, and their services were less resilient than they are now. If, for example, they can’t reach the movie recommendation service to retrieve the last recommendations for a customer by a given time, they’ll instead fetch some slightly stale results from a cache and show you that instead. You probably won’t notice, and even if you do, it will just be slightly puzzling—“Why on earth is it recommending that again?”
Other, less essential, parts of the Netflix homepage UX may not display at all if the service can’t be reached. As a software engineer, you’ll probably notice these things but many of the resultant changes are so small they’re almost imperceptible to the vast majority of users.
Of course there is no reason why you couldn’t apply graceful degradation in a carbon-aware way. For example, by performing a cache discard and refreshing the movie recommendations list only when the electricity you are using is (or is projected to be) greenest.
The approach is particularly applicable when a use case isn’t latency sensitive. AI training is a good example. If you are training a Large Language Model, you could choose to do so only when the electricity is greenest.
The pushback you may receive is based on commercial pressures—“We need to get this model built fast so we’re not behind our competitor”—but taking longer to do something the right way may actually pay dividends. If you say so publicly—“We’re taking a little longer over our GenAI strategy as we want to do it in a sustainable way”—some of your customers might be more likely to wait for your product to ship and, by not rushing, you can avoid some of the pitfalls that happen when you ship a product before it is ready, such as telling your customers to to eat rocks and glue.
Demand shifting can also be based on location. For example, to reduce carbon intensity, you could move to different hemispheres seasonally to maximize exposure to sunlight and solar power. It’s analogous to having call centres in different regions so that you can offer 24/7 support without needing people to work unsocial hours.
Moving your workloads may be straightforward but if they depend on large amounts of persistent data, moving that data is harder and slower and may not be practical. You may also have to get to grips with data sovereignty laws, which can be another challenging hurdle.
Demand shifting might sound purely theoretical but there are, in fact, several real-world examples of demand shifting in practice:
- Google launched a project to make some cloud workloads carbon aware. It says that it “can now shift moveable compute tasks between different data centres, based on regional hourly carbon-free energy availability”.
- Microsoft announced a project to make Windows 11 more sustainable by running Windows updates when the carbon intensity is lower.
- Another microsoft product, Xbox, now performs updates when the electricity from the grid is the cleanest, and its power-saving mode ‘Shutdown’ can cut electricity consumption up to 20-fold.
- Apple has Clean Energy Charging for US iPhone customers that uses a forecast of the carbon emissions in your local energy grid in order to charge your iPhone during times of cleaner energy production.
Green software architecture requires savvy and should not be underestimated. Keep in mind that cloud providers monitor where workloads are and may wish to build a new data centre if they see a spike in demand. You do not want to encourage anyone to pour more concrete and build new servers, given all the greenhouse gas emissions that will be generated, especially if you are going to be in the data centre for a short time. Network traffic has a carbon cost, and locations have performance implications.
Demand shaping
The other technique is demand shaping. It is similar to demand shifting, but instead of moving demand to a different region or time, we shape customer demand in line with the carbon intensity of the existing electricity supply. As such, it may be more applicable in cases where workloads are more latency sensitive.
This approach, also known as ‘demand responsive’ design, is being taken by ClimateAction.tech CIC’s magazine, Branch. Sustainable digital product designer, Tom Jarrett, describes in a blog post how Branch uses data from a grid intensity API plus the user’s location, to “adapt to and reflect the physical infrastructure of the internet and the energy behind.”
Branch is the only real-world example I’ve found, but there are plenty of other places where we do similar things for other reasons.
Video conferencing software shapes demand by reducing the video quality and prioritising audio. This was particularly obvious during COVID lockdowns, when use of tools like Zoom increased by a staggering amount. We sometimes looked a bit pixelated on our conference calls, but it was mostly fine.
Video streaming services like the aforementioned Netflix use adaptive bitrate streaming to achieve a similar result. The idea here is that multiple versions of video files are created and encoded ahead of time to fit a variety of network conditions. Then, based on factors like bandwidth and device type, the video player selects the highest-quality file that the device can play, with the smallest amount of buffering possible. Again, during COVID, this happened a lot; our movies were a bit grainier but we could still watch them.
You might also think of examples like progressive enhancement in web design, where the web experience becomes more whizzy depending on the resources and bandwidth of the end user’s device, or TCP/IP, where the transfer speed increases in response to how much data can be broadcast over the wire.
Demand shaping can be largely invisible, as it is in these examples, but you could also give control of it to users of your application or visitors to your site. If you use a washing machine or dishwasher, it probably has an eco cycle which takes longer but uses less electricity by washing at lower temperatures of 30 degrees or less. Most washing machine eco cycles also use less water, by increasing the drum movements to ensure your laundry is cleaned effectively.
On a website you could have a ‘Low Carbon Intensity’ button or slider that reduces the graphical intensity of the site. You might imagine this would be too niche for most of your users to care about, but you may find that some people use it because they care about their environment while others may genuinely prefer a site with fewer visual distractions.