Slide 1

Slide 1 text

Holly Cummins Senior Principal Software Engineer, Quarkus @[email protected] Writing Greener Java Applications Red Hat

Slide 2

Slide 2 text

@holly_cummins #RedHat Sources: https://www.greenit.fr/wp-content/uploads/2019/11/GREENIT_EENM_etude_EN_accessible.pdf https://ourworldindata.org/ghg-emissions-by-sector the digital world creates more carbon emissions than aviation

Slide 3

Slide 3 text

@holly_cummins #RedHat Lighter area represents high and low estimates, where available. Sources: https://www.iea.org/fuels-and-technologies/data-centres-networks https://ourworldindata.org/grapher/electricity-demand?tab=table&country=USA~GBR~FRA~DEU~IND~BRA data centres use as much electricity as a medium country

Slide 4

Slide 4 text

@holly_cummins #RedHat aaaaaaaargh

Slide 5

Slide 5 text

@holly_cummins #RedHat aaaaaaaargh?

Slide 6

Slide 6 text

@holly_cummins #RedHat be a solutionist

Slide 7

Slide 7 text

@holly_cummins #RedHat what should we do?

Slide 8

Slide 8 text

@holly_cummins #RedHat • right thing to do • business benefits • lower costs • higher ESG score • competitive advantage • recruitment advantage should we reduce our greenhouse gases?

Slide 9

Slide 9 text

@holly_cummins #RedHat

Slide 10

Slide 10 text

Usefulness (value) Measurement for optimization User behaviour Software Hosting Data storage Demand shaping Hardware efficiency Energy efficiency Application efficiency Utilization Demand shifting to reduce carbon intensity Infrastructure efficiency (PUE) Electricity source principles of green software engineering Network

Slide 11

Slide 11 text

step 1: electricity source

Slide 12

Slide 12 text

@holly_cummins #RedHat data center location matters (these are made-up energy mixes)

Slide 13

Slide 13 text

@holly_cummins #RedHat

Slide 14

Slide 14 text

@holly_cummins #RedHat we need to talk about virginia

Slide 15

Slide 15 text

@holly_cummins #RedHat look at the sustainability information before choosing a hosting region

Slide 16

Slide 16 text

@holly_cummins #RedHat look at the sustainability information before choosing a hosting region choose a cloud provider who make this easy

Slide 17

Slide 17 text

@holly_cummins #RedHat time of day matters • renewables are not “steady supply” • if grid load is high, shortfalls are filled by fossil fuels

Slide 18

Slide 18 text

@holly_cummins #RedHat “carbon-aware”

Slide 19

Slide 19 text

@holly_cummins #RedHat “carbon-aware”

Slide 20

Slide 20 text

@holly_cummins #RedHat “carbon-aware” a data problem an orchestration problem

Slide 21

Slide 21 text

@holly_cummins #RedHat step 2: the four vowels

Slide 22

Slide 22 text

@holly_cummins #RedHat step 2: the four vowels

Slide 23

Slide 23 text

@holly_cummins #RedHat step 2: the four vowels elasticity

Slide 24

Slide 24 text

@holly_cummins #RedHat step 2: the four vowels elasticity utilisation

Slide 25

Slide 25 text

@holly_cummins #RedHat step 2: the four vowels elasticity utilisation

Slide 26

Slide 26 text

@holly_cummins #RedHat step 2: the four vowels elasticity utilisation efficiency

Slide 27

Slide 27 text

@holly_cummins #RedHat step 2: the four vowels elasticity utilisation efficiency utility

Slide 28

Slide 28 text

@holly_cummins #RedHat elasticity we used to leave our applications running overnight when we scripted turning them off, we reduced our cloud bill by 30% @darkandnerdy, Chicago DevOpsDays

Slide 29

Slide 29 text

@holly_cummins #RedHat

Slide 30

Slide 30 text

#RedHat @holly_cummins 2017 survey 25% of 16,000 servers doing no useful work

Slide 31

Slide 31 text

#RedHat @holly_cummins 2017 survey 25% of 16,000 servers doing no useful work “perhaps someone forgot to turn them off”

Slide 32

Slide 32 text

@holly_cummins #RedHat ultimate elasticity

Slide 33

Slide 33 text

@holly_cummins #RedHat ultimate elasticity

Slide 34

Slide 34 text

@holly_cummins #RedHat turning it off and on again must ultimate elasticity

Slide 35

Slide 35 text

@holly_cummins #RedHat turning it off and on again must • be fast ultimate elasticity

Slide 36

Slide 36 text

@holly_cummins #RedHat turning it off and on again must • be fast • actually work ultimate elasticity

Slide 37

Slide 37 text

@holly_cummins #RedHat turning it off and on again must • be fast • actually work • idempotency ultimate elasticity

Slide 38

Slide 38 text

@holly_cummins #RedHat turning it off and on again must • be fast • actually work • idempotency • resiliency ultimate elasticity

Slide 39

Slide 39 text

@holly_cummins #RedHat

Slide 40

Slide 40 text

@holly_cummins #RedHat LightSwitchOps

Slide 41

Slide 41 text

@holly_cummins #RedHat LightSwitchOps

Slide 42

Slide 42 text

@holly_cummins #RedHat efficiency

Slide 43

Slide 43 text

@holly_cummins #RedHat what programming languages use the least energy?

Slide 44

Slide 44 text

@holly_cummins #RedHat what programming languages use the most energy?

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

energy efficiency of programming languages

Slide 47

Slide 47 text

@holly_cummins #RedHat

Slide 48

Slide 48 text

@holly_cummins #RedHat

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

@holly_cummins #RedHat “Our results show that some JVM platforms can exhibit up to 100% more energy consumption.” https://hal.inria.fr/hal-03275286/document

Slide 51

Slide 51 text

@holly_cummins #RedHat if JVM parameters can make that much difference … … what impact does the framework have?

Slide 52

Slide 52 text

@holly_cummins #RedHat

Slide 53

Slide 53 text

@holly_cummins #RedHat

Slide 54

Slide 54 text

@holly_cummins #RedHat does being small and fast reduce carbon footprint?

Slide 55

Slide 55 text

digression: measuring carbon is hard

Slide 56

Slide 56 text

@holly_cummins #RedHat step 1: measure power usage

Slide 57

Slide 57 text

@holly_cummins #RedHat step 1: measure power usage wall power measurement

Slide 58

Slide 58 text

@holly_cummins #RedHat step 1: measure power usage wall power measurement more complete

Slide 59

Slide 59 text

@holly_cummins #RedHat step 1: measure power usage wall power measurement more complete needs access to the wall

Slide 60

Slide 60 text

@holly_cummins #RedHat step 1: measure power usage wall power measurement more complete needs access to the wall and equipment

Slide 61

Slide 61 text

@holly_cummins #RedHat step 1: measure power usage wall power measurement more complete needs access to the wall and equipment and notebooks

Slide 62

Slide 62 text

@holly_cummins #RedHat step 1: measure power usage wall power measurement more complete needs access to the wall and equipment and notebooks RAPL

Slide 63

Slide 63 text

@holly_cummins #RedHat step 1: measure power usage wall power measurement more complete needs access to the wall and equipment and notebooks RAPL programmatically accessible

Slide 64

Slide 64 text

@holly_cummins #RedHat step 1: measure power usage wall power measurement more complete needs access to the wall and equipment and notebooks RAPL programmatically accessible misses some components

Slide 65

Slide 65 text

@holly_cummins #RedHat step 1: measure power usage wall power measurement more complete needs access to the wall and equipment and notebooks data costs carbon RAPL programmatically accessible misses some components

Slide 66

Slide 66 text

@holly_cummins #RedHat

Slide 67

Slide 67 text

@holly_cummins #RedHat

Slide 68

Slide 68 text

@holly_cummins #RedHat

Slide 69

Slide 69 text

@holly_cummins #RedHat load

Slide 70

Slide 70 text

@holly_cummins #RedHat Source: Teads EC2 instances carbon dataset

Slide 71

Slide 71 text

@holly_cummins #RedHat coal wind step 2: convert power usage to carbon solar

Slide 72

Slide 72 text

@holly_cummins #RedHat published energy mixes (these are made-up energy mixes)

Slide 73

Slide 73 text

@holly_cummins #RedHat published energy mixes … but methodologies are not open (these are made-up energy mixes)

Slide 74

Slide 74 text

@holly_cummins #RedHat published energy mixes … but methodologies are not open … or consistent (these are made-up energy mixes)

Slide 75

Slide 75 text

@holly_cummins #RedHat step 3: embedded carbon (manufacturing has costs)

Slide 76

Slide 76 text

@holly_cummins #RedHat simpler models

Slide 77

Slide 77 text

@holly_cummins #RedHat vrrrrrooooooooom model* * a made-up name

Slide 78

Slide 78 text

@holly_cummins #RedHat

Slide 79

Slide 79 text

@holly_cummins #RedHat these two columns are almost the same

Slide 80

Slide 80 text

@holly_cummins #RedHat energy consumption (sort of, mostly) is proportional to execution time

Slide 81

Slide 81 text

@holly_cummins #RedHat economic model*

Slide 82

Slide 82 text

@holly_cummins #RedHat economic model* * "economic input-output life cycle assessment"

Slide 83

Slide 83 text

@holly_cummins #RedHat reducing your cloud spend (probably) reducing your carbon footprint* hardware spend electricity bill * if you keep other factors the same

Slide 84

Slide 84 text

@holly_cummins #RedHat all models are wrong, some are useful

Slide 85

Slide 85 text

so … quarkus?

Slide 86

Slide 86 text

@holly_cummins #RedHat density Source: Clement Escoffier cost impact of framework choice Setup: • 800 requests/second, over 20 days • SLA > 99% • AWS instances Assumptions: • Costs are for us-east-1 data centre

Slide 87

Slide 87 text

@holly_cummins #RedHat Setup: • 800 requests/second, over 20 days • SLA > 99% Assumptions: • 50% load • us-east-1 data centre • Teads dataset Source: Clement Escoffier x Teads cloud carbon impact of framework choice

Slide 88

Slide 88 text

• quarkus cuts carbon by ~2x* • native has a slightly smaller carbon footprint * OOM heuristic density test: conclusions

Slide 89

Slide 89 text

@holly_cummins #RedHat capacity Source: John O’Hara Setup: • REST + CRUD • large heap • RAPL energy measurement Assumptions: • US energy mix CRUD climate impact at low load (single instance)

Slide 90

Slide 90 text

@holly_cummins #RedHat Setup: • REST + CRUD • large heap • RAPL energy measurement • multiple instances to support high load 
 Assumptions: • US energy mix Source: John O’Hara CRUD climate impact at high load (multiple instances)

Slide 91

Slide 91 text

• quarkus cuts carbon by ~2-3x* • native consumes more carbon than JVM capacity test: conclusions * OOM heuristic

Slide 92

Slide 92 text

@holly_cummins #RedHat so does quarkus reduce carbon emissions?

Slide 93

Slide 93 text

@holly_cummins #RedHat so does quarkus reduce carbon emissions?

Slide 94

Slide 94 text

@holly_cummins #RedHat so does quarkus reduce carbon emissions? quarkus ‘automatically’ saves

Slide 95

Slide 95 text

@holly_cummins #RedHat so does quarkus reduce carbon emissions? quarkus ‘automatically’ saves • time

Slide 96

Slide 96 text

@holly_cummins #RedHat so does quarkus reduce carbon emissions? quarkus ‘automatically’ saves • time • money

Slide 97

Slide 97 text

@holly_cummins #RedHat so does quarkus reduce carbon emissions? quarkus ‘automatically’ saves • time • money • carbon (~2x)

Slide 98

Slide 98 text

@holly_cummins #RedHat so does quarkus reduce carbon emissions? quarkus ‘automatically’ saves • time • money • carbon (~2x)

Slide 99

Slide 99 text

@holly_cummins #RedHat caveat • benchmarks vary • applications vary • if you have some edge case where performance is worse with quarkus, carbon footprint is also likely to be worse

Slide 100

Slide 100 text

@holly_cummins #RedHat but what about native? reminder

Slide 101

Slide 101 text

@holly_cummins #RedHat but what about native? use case for native reminder

Slide 102

Slide 102 text

@holly_cummins #RedHat but what about native? use case for native • low workload (throughput isn’t the bottleneck) reminder

Slide 103

Slide 103 text

@holly_cummins #RedHat but what about native? use case for native • low workload (throughput isn’t the bottleneck) • resource-constrained or old hardware (especially memory) reminder

Slide 104

Slide 104 text

@holly_cummins #RedHat but what about native? use case for native • low workload (throughput isn’t the bottleneck) • resource-constrained or old hardware (especially memory) • high re-deploy rate (applications never get warmed up before being spun down) reminder

Slide 105

Slide 105 text

@holly_cummins #RedHat but what about native? use case for native • low workload (throughput isn’t the bottleneck) • resource-constrained or old hardware (especially memory) • high re-deploy rate (applications never get warmed up before being spun down) • serverless (of course) reminder

Slide 106

Slide 106 text

@holly_cummins #RedHat but what about native? use case for native • low workload (throughput isn’t the bottleneck) • resource-constrained or old hardware (especially memory) • high re-deploy rate (applications never get warmed up before being spun down) • serverless (of course) use case for JVM reminder

Slide 107

Slide 107 text

@holly_cummins #RedHat but what about native? use case for native • low workload (throughput isn’t the bottleneck) • resource-constrained or old hardware (especially memory) • high re-deploy rate (applications never get warmed up before being spun down) • serverless (of course) use case for JVM • high workload (you need lots of throughput) reminder

Slide 108

Slide 108 text

@holly_cummins #RedHat but what about native? use case for native • low workload (throughput isn’t the bottleneck) • resource-constrained or old hardware (especially memory) • high re-deploy rate (applications never get warmed up before being spun down) • serverless (of course) use case for JVM • high workload (you need lots of throughput) • long-lived processes (the rapid start of native doesn’t save you much over the lifetime) reminder

Slide 109

Slide 109 text

@holly_cummins #RedHat but what about native? use case for native • low workload (throughput isn’t the bottleneck) • resource-constrained or old hardware (especially memory) • high re-deploy rate (applications never get warmed up before being spun down) • serverless (of course) use case for JVM • high workload (you need lots of throughput) • long-lived processes (the rapid start of native doesn’t save you much over the lifetime) • stable workload or very little elasticity in underlying orchestration reminder

Slide 110

Slide 110 text

@holly_cummins #RedHat use case for native • low workload (so throughput isn’t the bottleneck) • resource-constrained or old hardware (especially memory) • high re-deploy rate (applications never get warmed up before being spun down) • serverless (of course) 
 use case for JVM • high workload (you need lots of throughput) • long-lived processes (the rapid start of native doesn’t save you much over the lifetime) • stable workload or very little elasticity in underlying orchestration but what about native? to optimise carbon

Slide 111

Slide 111 text

@holly_cummins #RedHat yes, those are the same optimising • cost • application performance will also be optimising carbon

Slide 112

Slide 112 text

@holly_cummins #RedHat native vs JVM is not an either-or • consider hybrid deployment models • a strength of Quarkus is application code is the same for native and JVM

Slide 113

Slide 113 text

@holly_cummins #RedHat native CLIs? • native is not just for serverless • native Java makes great CLIs • is a CLI usually the most carbon- efficient way to do something?

Slide 114

Slide 114 text

@holly_cummins #RedHat elasticity native quarkus starts faster than a light bulb

Slide 115

Slide 115 text

@holly_cummins #RedHat but. an app starting fast isn’t elasticity … …unless you also stop the app

Slide 116

Slide 116 text

@holly_cummins #RedHat how does quarkus help reduce carbon? energy usage elasticity machine selection (provisioning)

Slide 117

Slide 117 text

@holly_cummins #RedHat how does quarkus help reduce carbon? energy usage ‘free’ direct easy to measure elasticity machine selection (provisioning)

Slide 118

Slide 118 text

@holly_cummins #RedHat how does quarkus help reduce carbon? energy usage ‘free’ direct easy to measure lower memory usage higher throughput for same resources elasticity machine selection (provisioning)

Slide 119

Slide 119 text

@holly_cummins #RedHat how does quarkus help reduce carbon? energy usage ‘free’ direct easy to measure lower memory usage higher throughput for same resources ‘enabled behaviours’ harder to measure real world impact depends on people taking advantage elasticity machine selection (provisioning)

Slide 120

Slide 120 text

@holly_cummins #RedHat how does quarkus help reduce carbon? energy usage ‘free’ direct easy to measure lower memory usage higher throughput for same resources ‘enabled behaviours’ harder to measure real world impact depends on people taking advantage elasticity machine selection (provisioning)

Slide 121

Slide 121 text

@holly_cummins #RedHat how does quarkus help reduce carbon? energy usage ‘free’ direct easy to measure lower memory usage higher throughput for same resources ‘enabled behaviours’ harder to measure real world impact depends on people taking advantage elasticity machine selection (provisioning) running the same workload on a smaller machine saves energy saves embodied carbon

Slide 122

Slide 122 text

@holly_cummins #RedHat how does quarkus help reduce carbon? energy usage ‘free’ direct easy to measure lower memory usage higher throughput for same resources ‘enabled behaviours’ harder to measure real world impact depends on people taking advantage elasticity machine selection (provisioning) scaling workloads down (ideally to 0) serverless a good example (but not the only one) running the same workload on a smaller machine saves energy saves embodied carbon

Slide 123

Slide 123 text

@holly_cummins #RedHat elasticity utilisation efficiency utility

Slide 124

Slide 124 text

@holly_cummins #RedHat we need a new mental model car: high max speed means high fuel usage per mile travelled

Slide 125

Slide 125 text

@holly_cummins #RedHat software: high max transactions means low carbon per transaction we need a new mental model car: high max speed means high fuel usage per mile travelled

Slide 126

Slide 126 text

@holly_cummins #RedHat “no-regrets” solutions

Slide 127

Slide 127 text

@holly_cummins #RedHat

Slide 128

Slide 128 text

@holly_cummins #RedHat co-benefits

Slide 129

Slide 129 text

@holly_cummins #RedHat co-benefits the double win

Slide 130

Slide 130 text

@holly_cummins #RedHat co-benefits the double win win-win

Slide 131

Slide 131 text

@holly_cummins #RedHat co-benefits the double win win-win win-squared

Slide 132

Slide 132 text

@holly_cummins #RedHat co-benefits the double win win-win win-squared 1 + 1 = 3

Slide 133

Slide 133 text

@holly_cummins #RedHat co-benefits the double win win-win win-squared 1 + 1 = 3 twofer

Slide 134

Slide 134 text

@holly_cummins #RedHat co-benefits the double win win-win win-squared 1 + 1 = 3 twofer überwinden

Slide 135

Slide 135 text

@holly_cummins #RedHat co-benefits the double win win-win win-squared 1 + 1 = 3 twofer überwinden the extra win

Slide 136

Slide 136 text

@holly_cummins #RedHat co-benefits the double win win-win win-squared 1 + 1 = 3 twofer überwinden the extra win

Slide 137

Slide 137 text

@holly_cummins #RedHat climate solutions can make everything better

Slide 138

Slide 138 text

@holly_cummins #RedHat remember the zombie servers? https://www.business2community.com/cloud-computing/overprovisioning-always-on-resources-lead-to-26-6-billion-in-public-cloud-waste-expected-in-2021-02381033

Slide 139

Slide 139 text

@holly_cummins #RedHat remember the zombie servers? $26.6 billion https://www.business2community.com/cloud-computing/overprovisioning-always-on-resources-lead-to-26-6-billion-in-public-cloud-waste-expected-in-2021-02381033

Slide 140

Slide 140 text

@holly_cummins #RedHat remember the zombie servers? $26.6 billion wasted https://www.business2community.com/cloud-computing/overprovisioning-always-on-resources-lead-to-26-6-billion-in-public-cloud-waste-expected-in-2021-02381033

Slide 141

Slide 141 text

@holly_cummins #RedHat remember the zombie servers? $26.6 billion wasted in 2021 https://www.business2community.com/cloud-computing/overprovisioning-always-on-resources-lead-to-26-6-billion-in-public-cloud-waste-expected-in-2021-02381033

Slide 142

Slide 142 text

@holly_cummins #RedHat the double-win turning things off saves a lot of money

Slide 143

Slide 143 text

@holly_cummins #RedHat the double-win turning things off saves a lot of money

Slide 144

Slide 144 text

@holly_cummins #RedHat the double-win renewable electricity is 9x cheaper

Slide 145

Slide 145 text

@holly_cummins #RedHat the double-win renewable electricity is 9x cheaper hosting in Finland:

Slide 146

Slide 146 text

@holly_cummins #RedHat the double-win renewable electricity is 9x cheaper hosting in Finland: 43% less carbon than the same workload in London

Slide 147

Slide 147 text

@holly_cummins #RedHat the double-win renewable electricity is 9x cheaper hosting in Finland: 43% less carbon than the same workload in London and it’s 15% cheaper

Slide 148

Slide 148 text

@holly_cummins #RedHat the double-win

Slide 149

Slide 149 text

@holly_cummins #RedHat the double-win

Slide 150

Slide 150 text

@holly_cummins #RedHat “this is not sacrifice. it’s advancement.”

Slide 151

Slide 151 text

@holly_cummins #RedHat we all have a part to play • choose your hosting wisely • use your buying power to encourage businesses to do make greener choices • turn things off when you’re not using them • choose an energy-efficient framework • all of this is a win anyway

Slide 152

Slide 152 text

slides thank you @[email protected]