API governance meets sustainability: Strategies for implementers

tyk-blog API governance meets sustainability

The IT sector is projected to consume 21% of global energy in the next decade. With sustainability now a crucial focus, it’s important to understand how API governance can drive efficiency and reduce environmental impact.

At the recent LEAP 2.0 API Governance Conference, the CNCF’s Nancy Chauhan and Gitpod’s Siddhant Khare shared their insights into how API governance can benefit the planet. Key elements of this include:

  • How combining governance and sustainability delivers efficiency
  • Quick wins to reduce your API-related carbon footprint
  • Handy tools for measuring and monitoring as you iron out inefficiencies

Why does API governance matter for environmental sustainability?

Broadly speaking, you can divide API governance into four areas:

  • Security and compliance
  • Standardization and consistency
  • Versioning and lifecycle management
  • Monitoring and observability

All companies should have standards and practices in place in relation to these four areas. Why? Because robust governance can strengthen API security, support a seamless compliance journey, enable efficient versioning and deliver crucial visibility – all of which deliver business value. Lack of governance, on the other hand, contributes to significant vulnerabilities and risks. The real-world example of almost 500 million Instagram users having their data scraped, including email addresses and locations, by hackers exploiting API endpoints in November 2024, highlights one such risk.

However, while API governance is essential, that doesn’t mean there aren’t things you can do when building APIs to help reduce unnecessary computing and optimize for energy use. Indeed, optimizing APIs can cut down on redundant computation, bandwidth usage and carbon emissions.

 

Creating an efficient and sustainable API strategy 

An effective API strategy combines governance and sustainability. Organizations need to move beyond just the functional and security aspects of APIs and think about the long-term impact. Doing so means implementing governance frameworks with sustainable practices, where you don’t just build efficient APIs but reduce both cost and emissions.

Integrating sustainability into API governance delivers several key benefits:

  • Lower resource consumption: Optimizing your API requests lowers CPU usage, which can reduce power consumption.
  • Reduced waste: API usage is exploding. If more APIs are reusable, data transfer requirements can reduce, leading to lower bandwidth costs and reduced emissions.
  • Compliance and transparency: Clearly tracking API energy consumption can help organizations align and comply with their sustainability goals.
  • Long-term resilience:  Green computing isn’t just an ethical choice but also a strategic advantage for organizations’ long-term business sustainability.

Sustainable API strategies

There are some quick wins when it comes to achieving superior API sustainability. Having a proper page edited API, for example, then introducing some adhesive compression to your API responses. Field filtering can also help, ensuring you filter responses for those you actually need for your product or service. Introducing a caching service is another quick win – one which also enhances the user experience across your products.

Other measures you can take include having a concurrency around your APIs, which is better for longer resiliency. You can also adopt a greener hosting solution, checking the carbon footprint of services such as AWS, GCP and so on.

Let’s consider a real-world example:

In this example, you have multiple large requests on a single server, resulting in high CPU usage and a large CO2 emission. Let’s say you introduce smaller payloads and divide the traffic with more sophisticated caching and on paging data. Reducing the traffic and optimizing the server leads to lower CO2 emissions.

Code examples and benchmarks

To move from concepts to implementation, we can consider a couple of code examples.

In the above, unoptimized example, the API retrieves 10,000 records and returns them all in a single response. This is a major inefficiency. The serialization bottleneck and multiple users hitting the endpoint can cause spikes in CPU usage. There’s network congestion, with too much data at once, leading to slowdowns. The inefficient design is wasting CPU, overloading the networks and increasing energy consumption.

Let’s consider the optimized example:

Here, quick wins included introducing pagination and GZIP compression, lowering the CPU and getting better bandwidth usage. You can clearly see the impact of this when looking at benchmarking results:

API governance tools to boost sustainability 

The are various tools that can help you analyze and enhance the sustainability impact of your APIs. Gprofiler, for example, helps you detect CPU usage for your API calls; it’s a handy measuring tool for the first step in strategically enhancing your sustainability.

Other helpful tools include Cloud Carbon Footprint (CCF), Kepler (Kubernetes-based efficient power level exporter and Scaphandre, all of which you can incorporate into your architecture to monitor and reduce the energy consumption of your APIs and also cloud workloads.

Take control of your API ecosystem

Whether you’re boosting your sustainability credentials or tackling API chaos, the right approach to governance makes all the difference. Does that mean that the best API governance strategy is a boring one? Find out in this recent article.