Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Imperial College London: Writing Greener Software

Imperial College London: Writing Greener Software

There is a real efficiency advantage in high compute density via managed cloud services. Such services, which can share resources between thousands or millions of users, can achieve extremely high hardware and energy utilisation. Because of this, an awful lot of the still rather limited publicly available material on writing software with sustainability in mind emphasises shifting to cloud services. But what happens if you can't?

Charles Humble

November 21, 2024
Tweet

More Decks by Charles Humble

Other Decks in Technology

Transcript

  1. @Charleshumble https://ourworldindata.org/ozone-layer?insight=the-initial-montreal-protocol-wouldn-t-have-been-successful-in-reducing-ozone-depleting- emissions-an-increase-in-ambition-from-subsequent-agreements-has-been-essential Ozone hole Emissions of the Ozone Depleting

    Substances (world) 200,000 tonnes 400,000 tonnes 600,000 tonnes 800,000 tonnes 1 million tonnes 1.2 million tonnes 1.4 million tonnes 1.6 million tonnes Methyl Chloroform Chlorofluorocarbons (CFCS) Carbon Tetrachloride Methly Bromide Hydrochloroflurocarbons (HCFCs) Haloms 1986 1990 1995 2000 2005 2010 2015 2021
  2. @Charleshumble https://www.epa.gov/climatechange-science/causes-climate-change The hockey stick 0.6 0.4 0.2 0.0 -0.0

    -0.4 -0.6 -0.8 0 1 2 3 4 5 6 -1 -2 -3 -4 Temperature Anomaly (°C) Standardised PAGES2K 1000 1200 1400 1600 1800 2000
  3. @Charleshumble https://info.container-solutions.com/the-cloud-native-attitude-2nd-edition Global data centre electricity use in 2021 was

    220-320   TWh, and if we factor in data transmission networks, we can add a further 260-340   TWh. For context, this makes the upper estimate of our industry’s electricity consumption similar to a country like Brazil, and much larger than a country like the UK, which used 331.3 TWh in the same period.
  4. @Charleshumble The cost of low carbon technology • In the

    last decade, the price of solar energy has fallen by more than 90%. • The price of wind energy by more than 70%. • Battery costs have also tumbled. https://www.weforum.org/agenda/2021/10/how-cheap-can-renewable-energy-get/
  5. @Charleshumble What do scopes 1, 2 and 3 mean? The

    Greenhouse Gas Protocol categorises GHG emissions into three “scopes”. SCOPE 1 Direct Emissions from operations owned or controlled by the reporting organiszation, such as onsite fuel combustion or fleet vehicles DIRECT EMISSIONS SCOPE 2 Indirect emmissions related to emission generation or purchased energy, such as heat and electricity. In 2015, the Corportate Standard was updated with comprehensive Scope 2 guidance INDIRECT EMISSIONS SCOPE 3 INDIRECT EMISSIONS Other indirect emissions from other activities, including all emissions from an organisation’s supply chain, business travel for employees and the electricity customers may consume when using a product
  6. @Charleshumble What do scopes 1, 2 and 3 mean? The

    Greenhouse Gas Protocol categorises GHG emissions into three “scopes”. SCOPE 1 Direct emissions from operations owned or controlled by the reporting organisation, such as onsite fuel combustion or fleet vehicles DIRECT EMISSIONS SCOPE 2 Indirect emissions related to emission generation or purchased energy, such as heat and electricity. In 2015, the Corporate Standard was updated with comprehensive Scope 2 guidance INDIRECT EMISSIONS SCOPE 3 INDIRECT EMISSIONS Indirect emissions from other activities, including all emissions from an organisation's supply chain, business travel for employees and the electricity customers may consume
  7. @Charleshumble What do scopes 1, 2 and 3 mean? The

    Greenhouse Gas Protocol categorises GHG emissions into three “scopes”. SCOPE 1 Direct emissions from operations owned or controlled by the reporting organisation, such as onsite fuel combustion or fleet vehicles DIRECT EMISSIONS SCOPE 2 Indirect emissions related to emission generation or purchased energy, such as heat and electricity. In 2015, the Corporate Standard was updated with comprehensive Scope 2 guidance INDIRECT EMISSIONS SCOPE 3 INDIRECT EMISSIONS Indirect emissions from other activities, including all emissions from an organisation's supply chain, business travel for employees and the electricity customers may consume
  8. @Charleshumble What do scopes 1, 2 and 3 mean? The

    Greenhouse Gas Protocol categorises GHG emissions into three “scopes”. SCOPE 1 Direct emissions from operations owned or controlled by the reporting organisation, such as onsite fuel combustion or fleet vehicles DIRECT EMISSIONS SCOPE 2 Indirect emissions related to emission generation or purchased energy, such as heat and electricity. In 2015, the Corporate Standard was updated with comprehensive Scope 2 guidance INDIRECT EMISSIONS SCOPE 3 INDIRECT EMISSIONS Indirect emissions from other activities, including all emissions from an organisation's supply chain, business travel for employees and the electricity customers may consume SCOPE 1 Direct emissions from operations owned or controlled by the reporting organisation, such as onsite fuel combustion or fleet vehicles DIRECT EMISSIONS SCOPE 2 Indirect emissions related to emission generation or purchased energy, such as heat and electricity. In 2015, the Corporate Standard was updated with comprehensive Scope 2 guidance INDIRECT EMISSIONS SCOPE 3 INDIRECT EMISSIONS Indirect emissions from other activities, including all emissions from an organisation's supply chain, business travel for employees and the electricity customers may consume
  9. @Charleshumble What are carbon neutral and net zero? • To

    be carbon neutral, an organisation must measure its scope 1 and 2 emissions, then match the total with emissions o ff sets through carbon reduction projects. • Net zero means reducing emissions according to the latest climate science, and balancing remaining residual emissions through carbon removals.
  10. @Charleshumble What does inspiring mean? • 24/7 carbon-free electricity in

    data centres: This means all electricity use in data centres is time- matched with green grid power, which is Google’s stated goal for 2030. https://www.gstatic.com/gumdrop/sustainability/247-carbon-free-energy.pdf
  11. @Charleshumble What does inspiring mean? • 24/7 carbon-free electricity in

    data centres: This means all electricity use in data centres is time- matched with green grid power, which is Google’s stated goal for 2030. • 10-year life expectancy on all end-user devices: Make hardware last longer and use it e ffi ciently to reduce embodied carbon. https://www.apple.com/environment/pdf/products/iphone/iPhone_14_PER_Sept2022.pdf
  12. @Charleshumble More efficient platforms • Many of the major platforms

    are making investments in terms of e ffi ciency—the JVM itself and modern frameworks such as Quarkus.
  13. @Charleshumble More efficient platforms • Many of the major platforms

    are making investments in terms of e ffi ciency—the JVM itself and modern frameworks such as Quarkus. • Python, which was languishing in our programming e ffi ciency table, is also improving.
  14. @Charleshumble Why start with ops? • Energy proportionality is an

    observation from Google that even an energy e ffi cient server still consumes about half its power when doing virtually no work. https://research.google/pubs/the-case-for-energy-proportional-computing/
  15. @Charleshumble Why start with ops? • Energy proportionality is an

    observation from Google that even an energy e ffi cient server still consumes about half its power when doing virtually no work. • Servers designed with less attention to energy e ff i ciency often idle at even higher power levels. https://research.google/pubs/the-case-for-energy-proportional-computing/
  16. @Charleshumble How do we get more efficient? A good fi

    rst goal would be to aim to have machine utilisation at >=50% at all times across your entire estate.
  17. @Charleshumble Start by getting rid of zombies • Zombies are

    any machines that were doing useful work but no longer are.
  18. @Charleshumble Start by getting rid of zombies • Zombies are

    any machines that were doing useful work but no longer are. • Get rid of them. Zombies are bad.
  19. @Charleshumble “In 2019, VMWare consolidated a data centre in Singapore.

    The team wanted to move the entire data centre and therefore investigated what exactly needed a migration. The result was somewhat shocking: 66% of all host machines were Zombies.” Martin Lippert, Spring Tools lead & sustainability ambassador at VMWare/Broadcomb, quoted in Building Green Software. https://www.oreilly.com/library/view/building-green-software/9781098150617/
  20. @Charleshumble “Some of the biggest cybersecurity incidents in recent times

    have stemmed from systems which no-one knew about and should never have been turned on.” - Ed Harrison, former head of security at Metaswitch Networks (now part of Microsoft), quoted in Building Green Software.
  21. @Charleshumble LightSwitchOps • One of the best encapsulations of this

    I’ve heard of comes from Red Hat’s Holly Cummins. She calls it “LightSwitchOps”. • A good place to start would be by turning o ff your test and development services in the evenings and at weekends. • If your business isn’t global you will have hours where you have peak demand and hours where you have much less demand. • So run an audit— fi nd out what your servers are doing—and get rid of anything you don’t need. If you know you can bring it back easily you can a ff ord to be brutal.
  22. @Charleshumble Datacenter specific wins • You have control over the

    lifetime of your hardware. • You can also take advantage of the power-saving features already present in your hardware. • Consider using more e ffi cient CPUs for the hardware you purchase. • You can even look at using a lower voltage within the range supported by the hardware.
  23. @Charleshumble Measurements and proxies • We often have to rely

    on proxies to calculate our environmental impact.
  24. @Charleshumble Measurements and proxies • We often have to rely

    on proxies to calculate our environmental impact. • One of the best proxies for energy is CPU utilisation.
  25. @Charleshumble Measurements and proxies • We often have to rely

    on proxies to calculate our environmental impact. • One of the best proxies for energy is CPU utilisation. • Cost is a useful proxy for carbon emissions—up to a point—unlike many other industries we don’t have to pay what Bill Gates calls “the green premium”.
  26. @Charleshumble Beyond proxies • If you have workloads on public

    clouds, then AWS (Customer Carbon Footprint Tool), Azure (Emissions Impact Dashboard) and Google Cloud (Carbon Footprint) all have strong sustainability goals and provide tools to assess your carbon footprint on their platforms.
  27. @Charleshumble Beyond proxies • If you have workloads on public

    clouds, then AWS (Customer Carbon Footprint Tool), Azure (Emissions Impact Dashboard) and Google Cloud (Carbon Footprint) all have strong sustainability goals and provide tools to assess your carbon footprint on their platforms. • Cloud Carbon Footprint is an open source alternative sponsored by Thoughtworks that can measure, monitor and reduce your carbon emissions on public clouds.
  28. @Charleshumble GSF Formula E: Energy consumed by a software system

    I: Location-based marginal carbon emissions M: Embodied emissions of a software system R: Functional unit (e.g., carbon per additional user, API call, machine learning job, etc.) https://learn.greensoftware.foundation/measurement/ SCI = ((E*I) + M ) per R energy consumed by software, in kWh Functional unit; this is how software scales, for example by user device or API request Carbon emitted per kWh of energy, in gC02/kWh Carbon emitted per kWh of energy, in gC02/kWh
  29. @Charleshumble Location, location, location • Putting your workloads where the

    electricity is greenest is an instant quick win. • Electricity Maps has partnered with Google, AWS and Salesforce to provide customers with real-time, global coverage of the carbon intensity of electricity. https://app.electricitymaps.com/map
  30. @Charleshumble Demand shifting • There are APIs such as WattTime

    and the Carbon Aware SDK from the Green Software Foundation.
  31. @Charleshumble Demand shifting • There are APIs such as WattTime

    and the Carbon Aware SDK from the Green Software Foundation. • Armed with these, you can apply a more advanced technique called demand shifting or shaping—responding to shifts in carbon intensity by increasing or decreasing your demand.
  32. @Charleshumble Demand shifting • There are APIs such as WattTime

    and the Carbon Aware SDK from the Green Software Foundation. • Armed with these, you can apply a more advanced technique called demand shifting or shaping—responding to shifts in carbon intensity by increasing or decreasing your demand. • Demand shifting can also be based on location.
  33. @Charleshumble Demand shifting • Some of the tricks and techniques

    we’ve learned to get more resilience in distributed computing can also be applied in a carbon- aware way. • For example, graceful degradation—such as retrieving data from a cache rather than generating it in real time if the data service is temporarily unavailable—is a widely used technique for microservices. Many of the resultant changes are so small they’re almost imperceptible to the majority of users. • Graceful degradation can also be applied 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 greenest.
  34. @Charleshumble Demand shifting examples • Google launched a project to

    make some cloud workloads carbon aware. It says it “can now shift moveable compute tasks between di ff erent data centres, based on regional hourly carbon- free energy availability”. https://blog.google/outreach-initiatives/sustainability/carbon-aware-computing-location/
  35. @Charleshumble Demand shifting examples • Google launched a project to

    make some cloud workloads carbon aware. It says it “can now shift moveable compute tasks between di ff erent 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. https://support.microsoft.com/en-us/windows/windows-update-is-now-carbon-aware-a53f39bc-5531-4bb1-9e78-db38d7a6df20
  36. @Charleshumble Demand shifting examples • Xbox 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. https://news.xbox.com/en-us/2023/01/11/xbox-carbon-aware-console-sustainability/
  37. @Charleshumble Demand shifting examples • Xbox 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 and uses it to charge your iPhone during times of cleaner energy production. https://support.apple.com/en-us/108068
  38. @Charleshumble Sidebar: AI • Although we know training and using

    AI consumes a lot of energy, publicly available information on the environmental cost of AI is scant.
  39. @Charleshumble Sidebar: AI • Although we know training and using

    AI consumes a lot of energy, publicly available information on the environmental cost of AI is scant. • Microsoft reported in May that its total carbon emissions have risen nearly 30% since 2020 primarily due to the construction of data centres to meet its push into AI. https://www.microsoft.com/en-us/corporate-responsibility/sustainability/report
  40. @Charleshumble Sidebar: AI • Although we know training and using

    AI consumes a lot of energy, publicly available information on the environmental cost of AI is scant. • Microsoft reported in May that its total carbon emissions have risen nearly 30% since 2020 primarily due to the construction of data centres to meet its push into AI. • Google’s emissions have surged nearly 50% compared to 2019. They also increased 13% year-on-year in 2023, according to their report. The company attributed the emissions spike to an increase in data centre energy consumption and supply chain emissions driven by arti fi cial intelligence. https://www.gstatic.com/gumdrop/sustainability/google-2024-environmental-report.pdf
  41. @Charleshumble Make sound choices • For any work that isn’t

    particularly latency sensitive, such as training a machine learning (ML) model, it’s smart to do it in a region with lower carbon intensity when you have access to the greenest power.
  42. @Charleshumble Make sound choices • For any work that isn’t

    particularly latency sensitive, such as training a machine learning (ML) model, it’s smart to do it in a region with lower carbon intensity when you have access to the greenest power. • Researchers from University College Dublin have found that practicing time-shifting methodologies for ML models can reduce software- related carbon emissions between 45% and 99% https://ieeexplore.ieee.org/document/6128960
  43. @Charleshumble Make sound choices • For any work that isn’t

    particularly latency sensitive, such as training a machine learning (ML) model, it’s smart to do it in a region with lower carbon intensity when you have access to the greenest power. • Researchers from University College Dublin have found that practicing time-shifting methodologies for ML models can reduce software- related carbon emissions between 45% and 99%. • Consider whether a pre-trained model would work, and also factor the carbon costs into your calculations. https://ieeexplore.ieee.org/document/6128960
  44. @Charleshumble Make sound choices • For any work that isn’t

    particularly latency sensitive, such as training a machine learning (ML) model, it’s smart to do it in a region with lower carbon intensity when you have access to the greenest power. • Researchers from University College Dublin have found that practicing time-shifting methodologies for ML models can reduce software- related carbon emissions between 45% and 99%. • Consider whether a pre-trained model would work, and also factor the carbon costs into your calculations. • Keep in mind that training is only part of the cost. https://ieeexplore.ieee.org/document/6128960
  45. @Charleshumble Make sound choices • Meta has stated that it

    “developed OPT-175B with energy e ff i ciency in mind by successfully training a model of this size using only 1/7th of the carbon footprint as that of GPT-3”. • Apple has said “we get tremendous e ffi ciency out of our silicon, which will continue to allow us to have 100% of our data centers carbon neutral and running entirely on renewable energy… That goal [of being entirely carbon neutral by 2030] is alive and well”.
  46. @Charleshumble Looking ahead • We are likely to see more

    regulations around sustainability, beyond calculating your Environmental, Social and Governance (ESG) rating, which many organisations are increasingly using as part of their vendor selection criteria. • The EU has announced the world’s fi rst Carbon Border Adjustment Mechanism (CBAM), which aims to make all EU suppliers green. Currently in a transition period, it will be fully operational in January 2026.
  47. @Charleshumble What else can you do? • Your best friends

    are likely to be your head of security, your CFO, and possibly your head of recruitment. • You have the opportunity to put pressure on your vendors to focus on e ffi ciency and sustainability. • With some caution I’d also encourage you to talk to maintainers of the larger open source libraries you use. Can they start thinking about sustainability? Can you help?
  48. @Charleshumble Summary If you are looking to start improving your

    software sustainability think operations fi rst, not code.
  49. @Charleshumble Summary If you are looking to start improving your

    software sustainability think operations fi rst, not code. Aim to reach >=50% utilisation for servers across your estate.
  50. @Charleshumble Summary • Apply LightSwitchOps, turn o ff under-utilised machines

    (zombies) and do manual rightsizing. • Use autoscaling where possible (including scaling down!) • Run more applications on the same hardware (multi-tenancy). • Use more e ffi cient CPUs that are matched with your workload requirements. • Look at where your workloads run from an environmental perspective using Electricity Maps and apply demand shifting.