Cloud-native technologies have revolutionized the way we build and deploy applications, enabling greater scalability, flexibility, and reliability. In this talk, Nico will explore the concept of sustainability in the context of cloud-native workloads and discuss the benefits of building sustainable applications.
Nico will cover best practices for designing and implementing sustainable cloud-native workloads, as well as share real-world examples.
This talk will guide you through the technical details of sustainable cloud-native workloads and provide actionable steps for everyone interested in building sustainable applications in the cloud.
3. Nico Meisenzahl
(Head of DevOps Consulting & Operations,
Cloud Solution Architect)
+49 8031 230159-0
nico.meisenzahl@whiteduck.de
@nmeisenzahl
www.linkedin.com/in/nicomeisenzahl
Who am I?
• Doing Cloud Native, Kubernetes & Azure
• Microsoft MVP
• Microsoft Azure
• Developer Technologies
• GitLab Hero
4. Agenda
• What is sustainability?
• Cloud-native & sustainable workloads
• Patterns & best-practice for cloud-native apps
• Real-world examples
• Current state & how to get started
4
6. 6
Sustainability means creating and maintaining software systems
with minimal negative impact on the environment, society, and the
economy.
In software development, the overall goal is to develop and operate
carbon-efficient applications. 🌱
7. Principles to be carbon efficient
• Energy Efficiency
• Carbon Awareness
• Hardware Efficiency
• Measurement
• Climate Commitments
7
8. Energy Efficiency
“Use the least amount of energy possible”
• most electricity is still generated by burning fossil fuels and is responsible
for 49%* of carbon emissions into the atmosphere
• already a common pattern for mobile apps
• needs to be expanded to all workloads
• waste as little as possible within the whole developer lifecycle
• also think about the end-user
• aim for a high utilization of compute resources
• the relationship between power consumption and utilization is not linear
8
* https://ourworldindata.org/co2-and-greenhouse-gas-emissions#co2-emissions-by-sector
9. Carbon Awareness
“Do more when the electricity is cleaner and do less when the
electricity is dirtier”
• carbon intensity varies depending on the time and place it is consumed
• prefer green energy over brown even if it comes with downsides
• we need to push/invest into green energy
• WattTime or Electricity Maps can help gaining insights by providing real-time
data and forecasts of the current carbon intensity on a specific location
• https://www.watttime.org
• https://www.electricitymaps.com
9
10. Hardware Efficiency
“Use the least amount of embodied carbon possible”
• longer backward compatibility for end-user devices (e.g., web apps)
• better utilize cloud compute resources
10
https://learn.greensoftware.foundation/assets/images/18_amortization-6471768431ab2f6432bee01b1c22d538.png
11. Measurement
“What you can't measure, you can't improve”
• Software Carbon Intensity (SCI) specification
• energy/hardware efficient and carbon awareness will decrease your SCI score
11
https://learn.greensoftware.foundation/assets/images/23_SCI-9b0c1ccc27826ea65f8ff754c8cc0fbd.png
12. Climate Commitments
“Understand the exact mechanism of carbon reduction”
• carbon neutral – must cover direct emissions (indirect is optional)
• no need reduce carbon emissions
• compensation to reduce emissions outside of their value chain
• net zero – the actual amount of carbon in the atmosphere remains constant
• through carbon removals (neutralizations)
• requires emissions reductions in line with a 1.5°C pathway
• carbon negative – remove more CO2 from the atmosphere than emitting
• 100% renewable – either “direct powered by” or via certificates
12
14. Sustainable workloads are…
• developed and operated while being aware of the environmental impact
• optimized for environmental impact
• maximize utilization while minimizing waste
• ultimately reducing the footprint on the environment
• carbon efficiency, i.e., emitting as few carbon emissions as possible
14
15. Isn’t cloud-native enough?
• it's a first step into the right direction, but you can do more
• you benefit from advantages through cloud native design patterns
• you rely on the commitment and work from Microsoft Azure
• but it’s still a shared responsibility
• “Azure services are up to 98 percent more carbon efficient and up to 93%
more energy efficient than a traditional enterprise datacenter”*
15
* https://datacenters.microsoft.com/globe/powering-sustainable-transformation
16. Microsoft commitments*
• $1 billion Climate Innovation Fund
• Commitment to protecting more land than we use by 2025
• Zero-waste certification by 2030
• Water positive by 2030 – replenish more water than we consume
• Diesel-free backup power by 2030
• 100 percent of our electricity consumption, 100 percent of the time, matched
by zero carbon energy purchases by 2030
16
* https://datacenters.microsoft.com/globe/powering-sustainable-transformation
19. An example: Sweden Region datacenter*
• launched in November 2021
• 30 percent reduction in energy costs and 90 percent less water usage
• free cooling – allows the warm air in the building to be mixed with cool outside air to
maintain the correct temperature
• rainwater harvesting – rain is captured and stored to be mainly to produce
humidification for cooling
• recycle and repurposing hardware using Microsoft’s Circular Center
• not yet needed in Sweden (hardware lifetime is about 6 years)
• Amsterdam Circular Center has resulted in 83 percent of hardware being reused
19
* https://news.microsoft.com/europe/features/how-microsofts-new-datacenter-region-in-sweden-incorporates-the-companys-sustainability-commitments
20. An example: Sweden Region datacenter*
• 100 percent renewable energy
• this can be ensured with near real-time monitoring and partnering with Vattenfall
• every megawatt hour consumed is matched with a MWh of renewable energy
generated during the same hour of consumption
• 45% lower net carbon dioxide emissions for backup power
• by using less carbon-intensive fuel (containing 50% renewable diesel)
20
* https://news.microsoft.com/europe/features/how-microsofts-new-datacenter-region-in-sweden-incorporates-the-companys-sustainability-commitments
21. Current status (Azure’s and yours)
• “2022 Environmental Sustainability Report”
• https://www.microsoft.com/corporate-responsibility/sustainability/report
• Emissions Impact Dashboard for Azure
• https://appsource.microsoft.com/product/power-bi/coi-
sustainability.emissions_impact_dashboard
• Power BI Pro license required
• Cloud for Sustainability API (Preview)
• https://learn.microsoft.com/industry/sustainability/api-overview
• currently no support for CSP and PAYG
21
23. Decide on the right location
• not the easiest one!
• you should choose a region
• near to your users
• relying on green energy
• even if there are downsides you should still prefer green energy over brown
• we need to invest in green energy to develop it further
• there might not be just one…
23
24. Demand shifting
• moving your energy consumption to different locations or times of days
where the carbon intensity is lower
• spatial shifting vs. temporal shifting
• less energy demand results in lower carbon intensity (demand can be met
by renewable energy)
24
https://learn.greensoftware.foundation/assets/images/14_spatial_shifting-4949d342f2ff430edea67874a9eaad52.png
25. Demand shaping
• adapting your energy consumption around carbon intensity variability when
required
• scaling down and/or limit scaling
• eco-mode opt-in for end-users
25
https://learn.greensoftware.foundation/assets/images/16_demand_shaping-4d2d1021da9740ea3cd15a383874f4ed.png
26. Networking
• the goal is to further eliminate unnecessary traffic
• implement a CDN (Content Delivery Network) for static assets
• follow caching best practices to reduce requests
• enable network compression
• implement DDoS protection
• opt-in for TLS termination where possible
26
27. Optimize for efficiency
• think about your overall hardware utilization
• the energy does not increase linearly with consumption
• utilize auto-scaling, bursting capabilities (B-Series VMs) & Spot VMs
• latter utilize the otherwise wasted capacity
• rely on Platform as a Service (PaaS)
• managed services are highly optimized and operate on more efficient hardware
• better overall utilization
• build your application based on serverless (Azure Functions)
• delete zombie workloads
• and implement a process to clean them up 27
28. Microservices
• think about moving to a microservice architecture
• but: they come with an overhead
• monoliths can still be the best choice for smaller applications
• also, don’t build micro-monoliths (not only because of the network overhead)!
• extra overhead on the CI/CD parts
• they allow to scale parts of the application independent form each other
• opt-in for containerization for smaller footprint
28
29. Think about your data
• Data is gold – but think about how to store it!
• store less frequent requested data to cold or archive storage
• only store what is relevant
• no data is the most sustainable data 😉
• revise your backup and retention policies
• optimize the collection of your metrics & logs
• again, think about what you really need
• also optimize your application logging to not create data you don’t need
29
31. Rethink your UI/UX
• reduce the components to load and render
• use optimized assets
• don’t render full-size images as thumbnails (network traffic, local CPU usage)
• decide to use lower resolutions in general
• rely on system fonts
• provide an optional eco-mode (opt-in)
• enabled dark-mode
• shifting async jobs to times where green energy is available
• reduced UI
31
32. Optimize your database (access)
• invest in reducing your database load
• optimize your database queries & indexes
• implement caching where possible
• validate & rework your data design
• this can save a lot of compute & energy
• positive side effect: your applications performance will increase
32
33. Optimize your code
• implement circuit breaker patterns
• repeated failures can lead to overhead and unnecessary processing
• optimize your code for efficient resource usage
• use optimized and efficient algorithms and design patterns
• rely the “don't repeat yourself” (DRY) principle
• rely on asynchronous access patterns
• queue and buffer requests, then process in batch
• actively decide when and where to process them
• invest into your legacy code
• identify inefficient code and start modernizing it
33
34. ARM-based compute resources
• “Ampere Altra VMs outperform equivalently sized Intel and AMD instances
from the same generation by 39% and 47%, respectively. In addition to being
the high-performance choice, Ampere Altra processors are extremely power
efficient, directly reducing users’ overall carbon footprint”*
• if you don’t care, move your workload to ARM-based resources
• otherwise, invest time to migrate
• make use of ARM-based resources in runtime and build time (CI/CD)
34
* https://amperecomputing.com/en/blogs/ampere-altra-now-available-on-microsoft-azure-cloud-platform
35. server-side vs. client-side rendering
• again, this isn’t an easy one
• do you know your end-users?
• server-side pros
• you can opt-in for green energy and better utilization
• less chatty (browser-to-server round-trips) and centralized caching
• lower requirements on the client-side
• client-side pros
• no need for a server, as you can rely on static storage
• it’s more efficient only to render what's needed
• less network traffic
35
36. Improve API efficiency
• GraphQL can help with chatty I/O antipattern
• “GraphQL is a query language for APIs and a runtime for fulfilling those queries with
your existing data”
• reduce unnecessary load with rate limits and throttling
• implement caching to reduce workload on your backends
• e.g., implement caching via API Management
36
37. Think about your CI/CD
• rely on shared resources like managed agents
• implement scaling to zero with VM scale sets or containerization
• e.g., run your CI/CD jobs in a shared Kubernetes Cluster
• optimize your pipeline for caching
• don’t build identical things multiple times
• split large code repos (to be able to build just parts of your code)
• reduce your GitOps sync interval
37
38. Testing is energy intensive
• rely on demand shifting for your integration, performance, load, or any
other intense testing
• move them to a different time or region to reduce carbon intense
• implement chaos engineering
• introduction of chaos engineering can significantly help improve reliability and
resilience and how the applications react to failures
• allows you optimizing your workload to handle failures gracefully with less wasted
resources
38
39. Don’t use AI for everything! Sorry…
• AI can help to be more sustainable
• e.g., Microsoft uses AI in there Sweden datacenters to manage green energy
consumption
• but AI requires extensive resources for training and hosting models*
• rely on it, but only for use-cases where AI really shines
• do not build the next chat bot
• use it selectively in particular use cases or parts of it
39
* https://sustainabilitymag.com/sustainability/sustainability-applications-for-artificial-intelligence
40. Kubernetes Event-driven Autoscaling (KEDA)
• allows scaling workload on Kubernetes based on events
• cron scaler allows to stop workload outside of business hours
• “Carbon Aware KEDA Operator” also allows carbon-aware scheduling
40
https://user-images.githubusercontent.com/966110/232321762-bb114716-f719-4e1f-9dc0-20680c94ab52.png
41. Carbon Aware KEDA Operator
• use carbon intensity data from third party sources such as WattTime,
Electricity Map or any other provider, to dynamically adjust the scaling
• integrates with any KEDA scaler
• allows scaling to zero (as it relies on KEDA)
• more details and current status
• https://github.com/Azure/carbon-aware-keda-operator
• https://www.tfir.io/carbon-aware-kubernetes-scaling-a-step-towards-greener-cloud-
computing
• https://github.com/kedacore/keda/issues/3467
41
42. Kubernetes Carbon Intensity Exporter
• retrieves the 24-hour carbon intensity forecast data every 12 hours and
stores it into a ConfigMap to be consumed
• therefore, can be used with any application
• currently supports Watttime only
• also used by KEDA Operator
• https://github.com/Azure/kubernetes-carbon-intensity-exporter
42
43. eBPF & Sustainability
• dynamically program the kernel for efficient networking, observability,
tracing, and security
• https://ebpf.io
• Cilium for scaling Kubernetes networking
• Tetragon for efficient Kubernetes security
• Kubernetes-based Efficient Power Level Exporter (Kepler)
43
https://ebpf.io/static/diagram-b6b32006ea52570dc6773f5dbf9ef8dc.svg
44. Kubernetes Efficient Power Level Exporter (Kepler)
• leverages eBPF to probe per-container energy consumption and exports
them as metrics
• these metrics allowing users to monitor their containers and nodes energy
consumption
• https://github.com/sustainable-computing-io/kepler
44
https://github.com/sustainable-computing-io/kepler/blob/main/doc/dashboard.png
45. Carbon-Aware SDK
• at its core the Carbon Aware SDK provides an API, CLI, and C# Library to
assist in building carbon aware software
• https://github.com/Green-Software-Foundation/carbon-aware-sdk
• supports Watttime and Electricity Maps
• is also used by Kepler
45
https://github.com/Green-Software-Foundation/carbon-aware-sdk/blob/dev/images/screenshot_web_api.png
46. Distributed Application Runtime (Dapr)
• helps building APIs for portable and reliable microservices
• assists implementing patterns like async communications, retries and circuit
breaker
• first-class implementations (clean and optimized code)
• based on Golang*
46
* https://greenlab.di.uminho.pt/wp-content/uploads/2017/10/sleFinal.pdf https://dapr.io/images/banner-image.png
48. Awareness is rising
• “Gartner Says Three Emerging Environmental Sustainability Technologies
Will See Early Mainstream Adoption by 2025”
• https://www.gartner.com/en/newsroom/press-releases/2022-04-21-gartner-says-
three-emerging-environmental-sustainability-technologies-will-see-early-
mainstream-adoption-by-2025
• the tooling ecosystem and projects are still in early stages
• in development, the current focus is on carbon and energy reduction
• not yet about water consumption and waste
48
49. Get started
• Basics
• https://greensoftware.foundation
• https://principles.green
• https://learn.microsoft.com/en-us/azure/well-architected/sustainability
• https://github.com/Green-Software-Foundation/awesome-green-software
• Container & Kubernetes focus
• https://github.com/cncf/tag-env-sustainability
• German sustainability meetup
• https://www.greenmanifesto.de
49