liveBook · Manning

Carbon-aware pattern

As explained in The Art of Code

The carbon-aware pattern is a green design pattern that schedules computation according to electricity carbon intensity and adjusts its location or scale accordingly.

The carbon-aware pattern makes software sensitive to electricity carbon intensity, so computation can move to cleaner times or regions instead of running whenever and wherever resources are available. section 8.4.7

Use three complementary adjustments:

  • Time shifting schedules energy-intensive work when the grid is cleaner, such as during periods with more wind, solar, hydro, or nuclear power. section 8.4.7
  • Location shifting runs heavy computation in a lower-carbon region when deployment spans multiple data centers. section 8.4.7
  • Workload scaling reduces resource usage when electricity is more carbon-intensive. section 8.6

Delay a daily report

Before launching a heavy daily business report, query the WattTime forecast endpoint for predicted carbon intensity over the next several hours. Select the lowest-emission window, while enforcing a maximum delay so the report still runs at least once per day. section 8.4.7

Table 8.1 The seven green design patterns
Pattern
Problem
Solution
Frugality
Unused features and overengineered architectures waste CPU, memory, and development effort.
Build only what provides real value and keep features and technical choices minimal.
Lean packaging
Packages become bloated with unused dependencies and dead code.
Remove unnecessary libraries and code to produce smaller, lighter artifacts.
Lean storage
Systems accumulate too much data and operational waste.
Store only the data needed, use efficient formats, and delete accumulated waste regularly.
Lean communication
Systems perform excessive network calls with large payloads.
Reduce request frequency, use caching, and minimize payload size.
Efficient execution
Inefficient or careless logic forces the system to perform unnecessary computation.
Use better algorithms and smooth workloads.
Memory efficiency
Applications retain more data in memory than required.
Hold only the data the system actively needs, release resources promptly, and use lightweight structures.
Carbon aware
Tasks run when or where electricity is most carbon-intensive.
Shift work to cleaner times or regions and adjust capability based on grid intensity.

Compare carbon-aware execution with the other green design patterns, including frugality, lean storage, lean communication, efficient execution, and memory efficiency. section 8.4.7

How The Art of Code covers it

How deep it goes
Explains the pattern through three strategies and a report-scheduling scenario, but does not detail implementation beyond carbon-intensity data access.
Examples
Uses analytics, exports, data processing, daily business reports, and Windows 11 updates as scheduling examples.
What you can do after
Apply it via the WattTime API by selecting cleaner execution windows while preserving a maximum-delay guarantee.
How it connects
Connects electricity carbon intensity with time shifting, location shifting, and workload scaling.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Art of Code. The section links point to the parts of the book it draws on.