How edge computing can reduce your software's carbon footprint
Tags: programming, edge, greensoftware
Published: 2023-08-17 11:02:57

I think often about how I can apply my skills as a software engineer in ways that contribute to the betterment of society. The climate crisis in particular is one where on an individual level I don't always feel like I can do much.

At the QCon London 2023 conference, my favourite track was "[Architecture with Sustainability in Mind](https://qconlondon.com/track/mar2023/architecture-sustainability-mind)". It left me feeling empowered to do something in my day-to-day work by showing how I could build software that has less of an impact on the environment by having both a sustainability mindset (e.g: asking how I could reduce the energy consumption of the software I build) and tools to help measure the impact of existing software.

Some of the talks, particularly Sara Bergman's '[Can Green Software Engineering Help Solve the Climate Crisis?](https://qconlondon.com/presentation/mar2023/can-green-software-engineering-solve-climate-crisis)'  and Adrian Cockcroft's '[Cloud Provider Sustainability, Current Status and Future Directions](https://qconlondon.com/presentation/mar2023/cloud-provider-sustainability-current-status-and-future-directions)', led me to consider how edge computing fits into this, and specifically:

_How, if at all, can using the edge reduce the carbon emissions of an application?_

Bergman's talk referenced this image from the International Energy Agency (IEA) that shows the increasing usage of data centres with respect to the number of workloads they run, the energy that they consume, and the energy consumed in the transmission of data in general:


![Global trends in digital and energy indicators, 2015 to 2022](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rugi1c4fbnvo4dcstumx.png)

As I've [spoken about before](https://youtu.be/Bg_lPsOhfuc), edge computing boosts the performance of our applications by processing and hosting data physically closer to our users.
 
By being closer to our users, edge computing reduces the carbon emissions of our software resulting from energy consumption in the following areas:

- Data centre workloads;
- Data centre energy use; and
- Data transmission network energy use.

It achieves this through the following:

## Lower request latencies

Request latency is tied to the energy used in the transmission of data over the network. When we have lower request latencies, this means less electricity being used - and essentially wasted - on waiting for a network response from distant servers. 

Idle resources still consume energy so the less time they wait, the better.

## Less data in the cloud

More data stored closer to the user (such as in an offline-first application) can mean less data that needs to be stored in the cloud. 

This means that you won't need as large of a database which would require a bigger machine (or multiple machines if it's sharded), which reduces the energy needed to store the data at the data centre.

## Reduced workloads going to the data centre

A reduction in workloads going to the data centre means that you can potentially reduce the size of the machines that you need to run to handle your application traffic at the data centre. 

Smaller machines = smaller energy usage at the data centre.
 
Smaller energy usage = a smaller carbon footprint.

That's math we like to see.

## Wrapping up

Based on the way edge computing operates as an architecture - run application logic and host data closer to our users - we can see that leveraging the edge can reduce the carbon footprint of our software through reduced energy usage.

If we as software developers start adopting the edge where we can - particularly for frequently invoked functionality - we can help in reducing technology's impact on the environment.

I had hoped to try and get some concrete numbers on the carbon emissions of an edge function run on a cloud computing provider relative to a serverless function hosted at a data centre using [Climatiq](https://www.climatiq.io/) but unfortunately their Cloud Computing API that could potentially help here isn't part of their free Community tier.

If anyone has recommendations on alternative tooling to measure this, comment on the post below!

Finally, if you'd like to learn more about building Green Software, I'd start with taking a look at the [Green Software Foundation](https://greensoftware.foundation/). They have a bunch of helpful resources and tools.