Holly Cummins
Senior Principal Software Engineer, Quarkus
J-Spring
June 21, 2023
@[email protected]
these five tricks can
make your Java apps
greener
cheaper &
nicer
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
it’s not just artificial intelligence
Slide 5
Slide 5 text
@holly_cummins #RedHat
it’s not just artificial intelligence
it’s not just cryptocurrency mining
Slide 6
Slide 6 text
@holly_cummins #RedHat
it’s not just artificial intelligence
it’s not just cryptocurrency mining
it’s all of us
Slide 7
Slide 7 text
@holly_cummins #RedHat
aaaaaaaargh
Slide 8
Slide 8 text
@holly_cummins #RedHat
aaaaaaaargh?
Slide 9
Slide 9 text
@holly_cummins #RedHat
be a solutionist
Slide 10
Slide 10 text
@holly_cummins #RedHat
how do we do make solutions?
Slide 11
Slide 11 text
@holly_cummins #RedHat
green software foundation: principles
Slide 12
Slide 12 text
@holly_cummins #RedHat
carbon
awareness
green software foundation: principles
Slide 13
Slide 13 text
@holly_cummins #RedHat
carbon
awareness
green software foundation: principles
where
Slide 14
Slide 14 text
@holly_cummins #RedHat
carbon
awareness
green software foundation: principles
where
when
Slide 15
Slide 15 text
@holly_cummins #RedHat
carbon
awareness
green software foundation: principles
hardware
efficiency
where
when
Slide 16
Slide 16 text
@holly_cummins #RedHat
carbon
awareness
green software foundation: principles
hardware
efficiency
where
when
elasticity
Slide 17
Slide 17 text
@holly_cummins #RedHat
carbon
awareness
green software foundation: principles
hardware
efficiency
where
when
elasticity
utilisation
Slide 18
Slide 18 text
@holly_cummins #RedHat
carbon
awareness
green software foundation: principles
hardware
efficiency
electricity
efficiency
where
when
elasticity
utilisation
Slide 19
Slide 19 text
@holly_cummins #RedHat
algorithms
carbon
awareness
green software foundation: principles
hardware
efficiency
electricity
efficiency
where
when
elasticity
utilisation
Slide 20
Slide 20 text
@holly_cummins #RedHat
algorithms
stack
carbon
awareness
green software foundation: principles
hardware
efficiency
electricity
efficiency
where
when
elasticity
utilisation
Slide 21
Slide 21 text
@holly_cummins #RedHat
algorithms
stack
carbon
awareness
hardware
efficiency
electricity
efficiency
where
when
elasticity
utilisation
green software foundation: principles
Slide 22
Slide 22 text
@holly_cummins
#RedHat
efficiency
Slide 23
Slide 23 text
@holly_cummins
#RedHat
what programming languages
use the least energy?
Slide 24
Slide 24 text
@holly_cummins
#RedHat
what programming languages
use the most energy?
Slide 25
Slide 25 text
No content
Slide 26
Slide 26 text
energy efficiency
of programming
languages
Slide 27
Slide 27 text
@holly_cummins
#RedHat
Slide 28
Slide 28 text
@holly_cummins
#RedHat
Slide 29
Slide 29 text
@holly_cummins
#RedHat
what’s the most carbon-efficient java?
Slide 30
Slide 30 text
@holly_cummins #RedHat
Slide 31
Slide 31 text
@holly_cummins #RedHat
Slide 32
Slide 32 text
@holly_cummins #RedHat
does being small and fast reduce carbon footprint?
Slide 33
Slide 33 text
#Quarkus @holly_cummins
measure, don’t guess.
Slide 34
Slide 34 text
digression:
measuring carbon is hard
Slide 35
Slide 35 text
@holly_cummins #RedHat
step 1: measure power usage
Slide 36
Slide 36 text
@holly_cummins #RedHat
step 1: measure power usage
wall power measurement
Slide 37
Slide 37 text
@holly_cummins #RedHat
step 1: measure power usage
wall power measurement
more complete
Slide 38
Slide 38 text
@holly_cummins #RedHat
step 1: measure power usage
wall power measurement
more complete
needs access to the wall
Slide 39
Slide 39 text
@holly_cummins #RedHat
step 1: measure power usage
wall power measurement
more complete
needs access to the wall
RAPL
Slide 40
Slide 40 text
@holly_cummins #RedHat
step 1: measure power usage
wall power measurement
more complete
needs access to the wall
RAPL
programmatically accessible
Slide 41
Slide 41 text
@holly_cummins #RedHat
step 1: measure power usage
wall power measurement
more complete
needs access to the wall
RAPL
programmatically accessible
misses some components
Slide 42
Slide 42 text
@holly_cummins #RedHat
step 1: measure power usage
wall power measurement
more complete
needs access to the wall
data costs carbon
RAPL
programmatically accessible
misses some components
@holly_cummins #RedHat
coal wind
step 2: convert power usage to carbon
solar
Slide 49
Slide 49 text
@holly_cummins #RedHat
published energy mixes
(these are made-up energy mixes)
Slide 50
Slide 50 text
@holly_cummins #RedHat
published energy mixes … but methodologies are not open
(these are made-up energy mixes)
Slide 51
Slide 51 text
@holly_cummins #RedHat
published energy mixes … but methodologies are not open
… or consistent
(these are made-up energy mixes)
Slide 52
Slide 52 text
@holly_cummins #RedHat
step 3: embedded carbon
(manufacturing has costs)
Slide 53
Slide 53 text
@holly_cummins #RedHat
simpler models
Slide 54
Slide 54 text
@holly_cummins #RedHat
all models are wrong, some are useful
Slide 55
Slide 55 text
@holly_cummins #RedHat
trick 1: the vrrrrrooooooooom model*
* a made-up name
Slide 56
Slide 56 text
@holly_cummins
#RedHat
Slide 57
Slide 57 text
@holly_cummins
#RedHat
these two columns
are almost the same
Slide 58
Slide 58 text
@holly_cummins #RedHat
energy consumption (sort of, mostly)
is proportional to execution time
Slide 59
Slide 59 text
@holly_cummins #RedHat
trick 2: the economic model*
Slide 60
Slide 60 text
@holly_cummins #RedHat
trick 2: the economic model*
* "economic input-output life cycle assessment"
Slide 61
Slide 61 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 62
Slide 62 text
so … quarkus?
Slide 63
Slide 63 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 64
Slide 64 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 65
Slide 65 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
economic model in action:
the cost and carbon metrics are
(roughly) the same
Slide 66
Slide 66 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
climate impact as a function of load
Slide 67
Slide 67 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
climate impact as a function of load
vrrrooom model in action:
quarkus on JVM has the smallest footprint …
because it has the highest throughput
Slide 68
Slide 68 text
@holly_cummins #RedHat
trick 3: use quarkus
Slide 69
Slide 69 text
@holly_cummins #RedHat
trick 3: use quarkus
quarkus ‘automatically’ saves
Slide 70
Slide 70 text
@holly_cummins #RedHat
trick 3: use quarkus
quarkus ‘automatically’ saves
• time
Slide 71
Slide 71 text
@holly_cummins #RedHat
trick 3: use quarkus
quarkus ‘automatically’ saves
• time
• money
Slide 72
Slide 72 text
@holly_cummins #RedHat
trick 3: use quarkus
quarkus ‘automatically’ saves
• time
• money
• carbon (~2x)
Slide 73
Slide 73 text
@holly_cummins #RedHat
trick 3: use quarkus
quarkus ‘automatically’ saves
• time
• money
• carbon (~2x)
• … even when Spring compatibility libraries are used
(almost no code changes except dependencies and tests)
Slide 74
Slide 74 text
@holly_cummins #RedHat
trick 3: use quarkus
quarkus ‘automatically’ saves
• time
• money
• carbon (~2x)
• … even when Spring compatibility libraries are used
(almost no code changes except dependencies and tests)
@holly_cummins #RedHat
application
utilisation
high utilisation
good case
Slide 80
Slide 80 text
@holly_cummins #RedHat
application
utilisation
over-utilisation
very bad case
Slide 81
Slide 81 text
@holly_cummins #RedHat
application
utilisation
over-utilisation
very bad case
under-utilisation
wasteful case
Slide 82
Slide 82 text
@holly_cummins #RedHat
application
elasticity
high utilisation
good case
@holly_cummins
Slide 83
Slide 83 text
@holly_cummins #RedHat
application
elasticity
scale-up
good utilisation
@holly_cummins
Slide 84
Slide 84 text
@holly_cummins #RedHat
application
elasticity
scale-down
good utilisation
@holly_cummins
Slide 85
Slide 85 text
#RedHat
@holly_cummins
2017 server-survey
25%
doing no useful work
(16,000 sampled)
Slide 86
Slide 86 text
#RedHat
@holly_cummins
2017 server-survey
25%
doing no useful work
(16,000 sampled)
“perhaps someone
forgot to turn them off”
Slide 87
Slide 87 text
#RedHat
@[email protected]
https://www.anthesisgroup.com/wp-content/uploads/2019/11/Comatose-Servers-Redux-2017.pdf
2014 server-survey
29%
active less than 5% of the time
(4,000 sampled)
@holly_cummins #RedHat
it’s not just electricity
it’s not just money
Slide 94
Slide 94 text
@holly_cummins #RedHat
it’s not just electricity
it’s water
it’s not just money
Slide 95
Slide 95 text
@holly_cummins #RedHat
it’s not just electricity
it’s water
it’s e-waste
it’s not just money
Slide 96
Slide 96 text
@holly_cummins
#RedHat
achieving elasticity
we used to leave
our applications
running all the time
when we
scripted turning
them off at night,
we reduced our
cloud bill by
30%
@darkandnerdy, Chicago DevOpsDays
Slide 97
Slide 97 text
@holly_cummins
#RedHat
yes, turning applications off is scary
Slide 98
Slide 98 text
@holly_cummins
#RedHat
what if … turning
applications off was
no more scary than
turning the lights off?
ultimate elasticity
Slide 99
Slide 99 text
@holly_cummins
#RedHat
Slide 100
Slide 100 text
@holly_cummins
#RedHat
Slide 101
Slide 101 text
@holly_cummins
#RedHat
turning it off and on again must
Slide 102
Slide 102 text
@holly_cummins
#RedHat
turning it off and on again must
• be fast
Slide 103
Slide 103 text
@holly_cummins
#RedHat
turning it off and on again must
• be fast
• actually work
Slide 104
Slide 104 text
@holly_cummins
#RedHat
turning it off and on again must
• be fast
• actually work
• idempotency
Slide 105
Slide 105 text
@holly_cummins
#RedHat
turning it off and on again must
• be fast
• actually work
• idempotency
• resiliency
Slide 106
Slide 106 text
@holly_cummins
#RedHat
architect things to be turned off and on often
Slide 107
Slide 107 text
@holly_cummins
#RedHat
trick 4:
LightSwitchOps
architect things to be turned off and on often
Slide 108
Slide 108 text
@holly_cummins
#RedHat
trick 4:
LightSwitchOps
architect things to be turned off and on often
Slide 109
Slide 109 text
#Quarkus @holly_cummins
you can’t optimise what you can’t measure
Slide 110
Slide 110 text
@holly_cummins #RedHat
FinOps
figuring out who in your company forgot to turn off their cloud
@holly_cummins #RedHat
algorithms
stack
carbon
awareness
hardware
efficiency
electricity
efficiency
where
when
elasticity
utilisation
green software foundation: principles
Slide 116
Slide 116 text
trick 5: electricity source
Slide 117
Slide 117 text
@holly_cummins #RedHat
data center location matters
Slide 118
Slide 118 text
@holly_cummins #RedHat
Slide 119
Slide 119 text
@holly_cummins #RedHat
Slide 120
Slide 120 text
@holly_cummins #RedHat
we need to talk
about virginia
Slide 121
Slide 121 text
@holly_cummins #RedHat
look at the sustainability information
before choosing a hosting region
Slide 122
Slide 122 text
@holly_cummins #RedHat
look at the sustainability information
before choosing a hosting region
choose a cloud provider who make this easy
Slide 123
Slide 123 text
@holly_cummins #RedHat
time of day matters
• (most) renewables are intermittent
• if grid load is high, shortfalls are filled
by fossil fuels
Slide 124
Slide 124 text
@holly_cummins #RedHat
aaaaaaaargh?
Slide 125
Slide 125 text
@holly_cummins #RedHat
“no-regrets” solutions
Slide 126
Slide 126 text
@holly_cummins
#RedHat
Slide 127
Slide 127 text
@holly_cummins
#RedHat
co-benefits
Slide 128
Slide 128 text
@holly_cummins
#RedHat
co-benefits
the double win
Slide 129
Slide 129 text
@holly_cummins
#RedHat
co-benefits
the double win
win-win
Slide 130
Slide 130 text
@holly_cummins
#RedHat
co-benefits
the double win
win-win
twofer
Slide 131
Slide 131 text
@holly_cummins
#RedHat
co-benefits
the double win
win-win
twofer
überwinden
Slide 132
Slide 132 text
@holly_cummins
#RedHat
co-benefits
the double win
win-win
twofer
überwinden
Slide 133
Slide 133 text
@holly_cummins #RedHat
climate solutions can
make everything better
Slide 134
Slide 134 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 135
Slide 135 text
@holly_cummins #RedHat
remember the zombie servers?
what else could we do
with that $26.6 billion
of wasted cloud spend?
https://www.business2community.com/cloud-computing/overprovisioning-always-on-resources-lead-to-26-6-billion-in-public-cloud-waste-expected-in-2021-02381033
Slide 136
Slide 136 text
@holly_cummins #RedHat
the double-win
turning things off saves a lot of money
Slide 137
Slide 137 text
@holly_cummins #RedHat
the double-win
renewable electricity is 9x cheaper
Slide 138
Slide 138 text
@holly_cummins #RedHat
the double-win
renewable electricity is 9x cheaper
hosting in Montreal:
Slide 139
Slide 139 text
@holly_cummins #RedHat
the double-win
renewable electricity is 9x cheaper
hosting in Montreal:
88% less carbon than the same workload in London
Slide 140
Slide 140 text
@holly_cummins #RedHat
the double-win
renewable electricity is 9x cheaper
hosting in Montreal:
88% less carbon than the same workload in London
and it’s 15% cheaper
Slide 141
Slide 141 text
@holly_cummins #RedHat
remember the vrrrrrooooooooom model?
(probably not, it was a made-up name)
Slide 142
Slide 142 text
@holly_cummins #RedHat
the double-win
Slide 143
Slide 143 text
@holly_cummins #RedHat
the double-win
Slide 144
Slide 144 text
@holly_cummins #RedHat
“this is not sacrifice. it’s advancement.”
– Dr. Jonathan Foley
Slide 145
Slide 145 text
@holly_cummins #RedHat
tl;dpa
(too long; didn’t pay attention)
trick 1: the vrrrooooom model says faster is greener
trick 2: the economic model says cheaper is greener
trick 3: choose a fast and energy-efficient framework
(such as quarkus)
trick 4: architect to be able to turn stuff off
(LightSwitchOps)
trick 5: choose your hosting wisely
Slide 146
Slide 146 text
@holly_cummins #RedHat
we all make a difference
Slide 147
Slide 147 text
slides
thank you
and don’t forget to vote in the J-Spring
app, which is running on Quarkus :)
@[email protected]