Your coding decisions can help save the planet

Irete Hamdani
5 min readDec 10, 2023

Following green software best practices will minimize your software’s carbon emissions and help curve climate change.

Co-written by: Cana Alpaslan, Deana Jirak, Chow Jia Yi, Serena Zhao, Irete Hamdani

An illustration of lines and squares that look like an abstracted circuit, with a dark blue background and lighter blue lines over it.

CO2 emissions are the leading cause of climate change

Carbon dioxide (CO2) is one of the greenhouse gases that trap heat in the atmosphere. While trapping heat is essential to sustain life on Earth, an increased concentration of gases can cause Earth to warm too much. This can lead to more extreme weather, biodiversity loss, forest fires, decreasing crop yields and unprecedented risks to human health.

Human activities, such as burning fossil fuels for energy, are releasing CO2 into the atmosphere at an unprecedented rate.

It is our responsibility as humans living on this planet to minimize our CO2 emissions to reduce the impact on the climate.

Software currently creates 4% of global CO2 emissions

The amount of CO2 emissions created by software is equivalent to the amount emitted from the entire aviation industry, and is expected to triple by 2030. The software industry’s emissions come from two primary sources: the software itself and the underlying hardware it operates on. Hardware has embodied carbon emissions through its sourcing and fabrication process, while software systems produce emissions through its electricity consumption.

Through more efficient application design and development, it is estimated that 85% of CO2 emissions generated by the industry could be impacted.

An infographic featuring 4 circuits in a horizontal row with arrows pointing in between to the right. From left to right, they read “Green software”, “Less energy used”, “Less CO2 emitted”, and “Less climate change”
When you use green software best practices, less energy is used, which causes less CO2 to be emitted, resulting in less climate change.

Green software

Green software is a discipline that defines, develops, and runs carbon-efficient software. Following green software best practices is the best way to reduce emissions created by your software. It also typically produces higher performing, more resilient, and less expensive solutions.

There are 4 main areas of impact:

  1. Coding
  2. Network Traffic
  3. Compute/Processing
  4. Storage

1. Coding best practices

Green software practices involve writing energy-efficient code by minimizing computational waste, optimizing algorithms, and adopting eco-friendly coding practices to reduce the carbon footprint associated with software development and execution.

Quick wins

  1. Use software patterns and architectures that best support data access and storage patterns.
  2. Refactor to reduce runtime and replace computationally intensive algorithms with simpler and more efficient version that produce the same result.
  3. Write efficient code: avoid unnecessary loops and calculations and remove unnecessary code such as sorting and formatting.

Larger scope improvements

  1. Choose compiled languages over interpreted languages where applicable and consider energy efficient programming languages such as C and Rust.
  2. Use a code profiler to identify areas of code that consume the most time or resources and optimize, (eg Amazon CodeGuru Profiler).
  3. Optimize applications to run efficiently on different devices, and ensure it is backwards compatible to reduce requiring hardware upgrade.

2. Network traffic best practices

Green software can reduce the energy consumption associated with data transmission by minimizing unnecessary network traffic, using data compression, and adopting intelligent routing strategies to lower the environmental impact of digital communication.

You can measure your impact by the GB transferred or packets transferred.

Quick wins

  1. Reduce client-server requests — cache static data, such as images or audio, instead of transferring it over the network.
  2. Reduce the size of data transmitted: Use managed audio and video streaming services with built-in compression. Enable payload data compression. Avoid resource-consuming animation and frameworks.
  3. Incorporate lazy loading, a technique where data is loaded only when it is needed.

Larger scope improvements

  1. Do ongoing customer journey analysis and optimize user paths.
  2. Incorporate a Content Delivery Network (CDN) — helps minimize latency through storing frequently read static data closer to consumers, and helps reduce the network traffic and server load.
  3. Maximize network utilization within the same cloud and region.

3. Compute and processing best practices

Green software focuses on optimizing processing tasks, such as resource-intensive computations, by utilizing energy-efficient hardware, load balancing, and parallel processing techniques to reduce energy consumption and increase computational efficiency.

You can measure your impact by vCPU minutes.

Quick wins

  1. Perform computationally intensive processes server side.
  2. Use spot instances instead of reserved where possible to take advantage of unused capacity in the cloud.
  3. Enable demand shifting — adopt autoscaling best practices to factor in when more renewable power is available.

Larger scope improvements

  1. Find out which resources are not utilized and execute a decommissioning plan (eg spinning down unused containers), keep resource utilization high and maximize energy efficiency.
  2. Only use AI if it will have a significant positive impact (that outweighs it’s negative impact) and prefer specific and smaller AI models.
  3. Enable demand shaping by changing the amount of processing you do on your applications depending on the carbon intensity.

4. Storage best practices

Green software can reduce the environmental impact by optimizing data storage, minimizing redundant information, and employing efficient data compression techniques to reduce the energy and resource requirements of data centers.

You can measure your impact by GB provisioned.

Quick wins

  1. Design schemas / database architecture to limit data redundancy.
  2. Compress data before storage and use size-optimized data formats.
  3. Delete any unused storage resource including irrelevant backups and images.

Larger scope improvements

  1. Maximize storage utilization: two storage units running at low utilization rates will consume more energy than one running at a high utilization rate.
  2. Employ efficient cold-storage strategies for database backups and server images.
  3. Set a retention policy on storage resources to automate the deletion of unused storage resources.

Resources

To learn more about green software, check out the following resources.

General resources

Tools

--

--