Upgrade to Pro — share decks privately, control downloads, hide ads and more …

These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer

These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer

The code we write has a climate impact. But how big is that impact? How do we measure it? How do we reduce it? Is the cloud helping? What’s going on with Virginia? Are we still allowed to do CI/CD? Will native compilation save us? Is Java even a good choice anymore? This talk discusses some of the trade-offs for a modern software developer, and provides a roadmap to figuring out the right thing.

Disclosure: Holly works on Quarkus. Along the way, she will talk about Quarkus sustainability measurements we’ve been doing … but it’s ok, because she promises that the Quarkus carbon data is exciting and interesting.

Holly Cummins

May 24, 2023
Tweet

More Decks by Holly Cummins

Other Decks in Programming

Transcript

  1. Holly Cummins


    Senior Principal Software Engineer, Quarkus


    GOTO Aarhus


    May 24, 2023


    @[email protected]
    These five tricks can
    make your apps


    greener


    cheaper &


    nicer

    View full-size slide

  2. @holly_cummins #RedHat

    View full-size slide

  3. @holly_cummins #RedHat
    compute for training large deep learning models


    300,000-fold


    increase in 6 years
    Dario Amodei and Daniel Hernandez. 2018. AI and Compute. https://openai.com/blog/ai-and-compute

    View full-size slide

  4. @holly_cummins #RedHat
    compute for training large deep learning models


    300,000-fold


    increase in 6 years
    Dario Amodei and Daniel Hernandez. 2018. AI and Compute. https://openai.com/blog/ai-and-compute

    View full-size slide

  5. @holly_cummins #RedHat
    it’s not just artificial intelligence

    View full-size slide

  6. @holly_cummins #RedHat
    it’s not just artificial intelligence
    it’s not just cryptocurrency mining

    View full-size slide

  7. @holly_cummins #RedHat
    it’s not just artificial intelligence
    it’s not just cryptocurrency mining
    it’s all of us

    View full-size slide

  8. @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

    View full-size slide

  9. @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

    View full-size slide

  10. @holly_cummins #RedHat
    aaaaaaaargh

    View full-size slide

  11. @holly_cummins #RedHat
    aaaaaaaargh?

    View full-size slide

  12. @holly_cummins #RedHat
    be a solutionist

    View full-size slide

  13. @holly_cummins #RedHat
    how do we do make solutions?

    View full-size slide

  14. @holly_cummins #RedHat
    green software foundation: principles

    View full-size slide

  15. @holly_cummins #RedHat
    carbon
    awareness
    green software foundation: principles

    View full-size slide

  16. @holly_cummins #RedHat
    carbon
    awareness
    green software foundation: principles
    where

    View full-size slide

  17. @holly_cummins #RedHat
    carbon
    awareness
    green software foundation: principles
    where
    when

    View full-size slide

  18. @holly_cummins #RedHat
    carbon
    awareness
    green software foundation: principles
    hardware
    efficiency
    where
    when

    View full-size slide

  19. @holly_cummins #RedHat
    carbon
    awareness
    green software foundation: principles
    hardware
    efficiency
    where
    when
    elasticity

    View full-size slide

  20. @holly_cummins #RedHat
    carbon
    awareness
    green software foundation: principles
    hardware
    efficiency
    where
    when
    elasticity
    utilisation

    View full-size slide

  21. @holly_cummins #RedHat
    carbon
    awareness
    green software foundation: principles
    hardware
    efficiency
    electricity
    efficiency
    where
    when
    elasticity
    utilisation

    View full-size slide

  22. @holly_cummins #RedHat
    algorithms
    carbon
    awareness
    green software foundation: principles
    hardware
    efficiency
    electricity
    efficiency
    where
    when
    elasticity
    utilisation

    View full-size slide

  23. @holly_cummins #RedHat
    algorithms
    stack
    carbon
    awareness
    green software foundation: principles
    hardware
    efficiency
    electricity
    efficiency
    where
    when
    elasticity
    utilisation

    View full-size slide

  24. @holly_cummins #RedHat
    algorithms


    stack
    carbon
    awareness
    hardware
    efficiency
    electricity
    efficiency
    where


    when
    elasticity


    utilisation
    green software foundation: principles

    View full-size slide

  25. trick 1: electricity source

    View full-size slide

  26. @holly_cummins #RedHat
    data center location matters

    View full-size slide

  27. @holly_cummins #RedHat

    View full-size slide

  28. @holly_cummins #RedHat

    View full-size slide

  29. @holly_cummins #RedHat
    we need to talk
    about virginia

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  32. @holly_cummins #RedHat
    time of day matters
    • (most) renewables are intermittent


    • if grid load is high, shortfalls are filled
    by fossil fuels

    View full-size slide

  33. @holly_cummins #RedHat
    move the workload
    to the greenest place

    View full-size slide

  34. @holly_cummins #RedHat
    move the workload
    to the greenest place

    View full-size slide

  35. @holly_cummins #RedHat
    move the workload
    to the greenest place
    a data problem

    View full-size slide

  36. @holly_cummins #RedHat
    move the workload
    to the greenest place
    a data problem
    an orchestration problem

    View full-size slide

  37. @holly_cummins #RedHat
    carbon
    awareness
    green software foundation: principles
    hardware
    efficiency
    electricity
    efficiency

    View full-size slide

  38. @holly_cummins #RedHat
    carbon
    awareness
    green software foundation: principles
    hardware
    efficiency
    electricity
    efficiency
    elasticity

    View full-size slide

  39. @holly_cummins #RedHat
    carbon
    awareness
    green software foundation: principles
    hardware
    efficiency
    electricity
    efficiency
    elasticity
    utilisation

    View full-size slide

  40. #RedHat
    @holly_cummins
    2017 server-survey


    25%


    doing no useful work


    (16,000 sampled)

    View full-size slide

  41. #RedHat
    @holly_cummins
    2017 server-survey


    25%


    doing no useful work


    (16,000 sampled)
    “perhaps someone
    forgot to turn them off”

    View full-size slide

  42. #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)

    View full-size slide

  43. @holly_cummins #RedHat

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  46. @holly_cummins #RedHat
    cloud elasticity?
    2021:
    $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

    View full-size slide

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

    View full-size slide

  48. @holly_cummins
    #RedHat
    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

    View full-size slide

  49. @holly_cummins #RedHat
    it’s not just electricity

    View full-size slide

  50. @holly_cummins #RedHat
    it’s not just electricity
    it’s water

    View full-size slide

  51. @holly_cummins #RedHat
    it’s not just electricity
    it’s water
    it’s e-waste

    View full-size slide

  52. @holly_cummins
    #RedHat
    yes, turning applications off is scary

    View full-size slide

  53. @holly_cummins
    #RedHat
    what if … turning
    applications off was
    no more scary than
    turning the lights off?

    View full-size slide

  54. @holly_cummins
    #RedHat
    ultimate elasticity


    View full-size slide

  55. @holly_cummins
    #RedHat
    ultimate elasticity


    View full-size slide

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


    View full-size slide

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


    View full-size slide

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


    View full-size slide

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


    View full-size slide

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


    View full-size slide

  61. @holly_cummins
    #RedHat
    architect things to be turned off and on often

    View full-size slide

  62. @holly_cummins
    #RedHat
    trick 2:
    LightSwitchOps
    architect things to be turned off and on often

    View full-size slide

  63. @holly_cummins
    #RedHat
    trick 2:
    LightSwitchOps
    architect things to be turned off and on often

    View full-size slide

  64. #Quarkus @holly_cummins
    you can’t optimise what you can’t measure

    View full-size slide

  65. @holly_cummins #RedHat
    FinOps
    figuring out who in your company forgot to turn off their cloud

    View full-size slide

  66. @holly_cummins #RedHat

    View full-size slide

  67. @holly_cummins #RedHat
    backstage.io

    View full-size slide

  68. @holly_cummins #RedHat
    backstage.io
    •cost insights plugin

    View full-size slide

  69. @holly_cummins #RedHat
    backstage.io
    •cost insights plugin
    •cloud carbon footprint plugin

    View full-size slide

  70. @holly_cummins #RedHat
    algorithms


    stack
    carbon
    awareness
    hardware
    efficiency
    electricity
    efficiency
    where


    when
    elasticity


    utilisation
    green software foundation: principles

    View full-size slide

  71. @holly_cummins
    #RedHat
    efficiency

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  74. energy efficiency
    of programming
    languages

    View full-size slide

  75. @holly_cummins
    #RedHat

    View full-size slide

  76. @holly_cummins
    #RedHat

    View full-size slide

  77. @holly_cummins
    #RedHat
    what’s the most carbon-efficient java?

    View full-size slide

  78. @holly_cummins #RedHat

    View full-size slide

  79. @holly_cummins #RedHat

    View full-size slide

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

    View full-size slide

  81. #Quarkus @holly_cummins
    measure, don’t guess.

    View full-size slide

  82. digression:


    measuring carbon is hard

    View full-size slide

  83. @holly_cummins #RedHat
    step 1: measure power usage

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  92. @holly_cummins #RedHat

    View full-size slide

  93. @holly_cummins #RedHat

    View full-size slide

  94. @holly_cummins #RedHat

    View full-size slide

  95. @holly_cummins #RedHat
    load

    View full-size slide

  96. @holly_cummins #RedHat
    Source: Teads EC2 instances carbon dataset

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  102. @holly_cummins #RedHat
    simpler models

    View full-size slide

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

    View full-size slide

  104. @holly_cummins #RedHat
    trick 3: vrrrrrooooooooom model*
    * a made-up name

    View full-size slide

  105. @holly_cummins
    #RedHat

    View full-size slide

  106. @holly_cummins
    #RedHat
    these two columns
    are almost the same

    View full-size slide

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

    View full-size slide

  108. @holly_cummins #RedHat
    trick 4: economic model*

    View full-size slide

  109. @holly_cummins #RedHat
    trick 4: economic model*
    * "economic input-output life cycle assessment"

    View full-size slide

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

    View full-size slide

  111. @holly_cummins #RedHat
    worked(ish) example:


    what’s the carbon footprint of ChatGPT?

    View full-size slide

  112. @holly_cummins #RedHat
    worked(ish) example:


    what’s the carbon footprint of ChatGPT?

    View full-size slide

  113. @holly_cummins #RedHat
    worked(ish) example:


    what’s the carbon footprint of ChatGPT?
    $50,000-
    $700,000


    running costs per day


    https://www.businessinsider.com/how-much-chatgpt-costs-openai-to-run-estimate-report-2023-4

    View full-size slide

  114. @holly_cummins #RedHat
    worked(ish) example:


    what’s the carbon footprint of ChatGPT?
    $3,000,000-


    $50,000,000


    training costs
    $50,000-
    $700,000


    running costs per day


    https://www.businessinsider.com/how-much-chatgpt-costs-openai-to-run-estimate-report-2023-4

    View full-size slide

  115. so … quarkus?

    View full-size slide

  116. @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

    View full-size slide

  117. @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

    View full-size slide

  118. @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

    View full-size slide

  119. @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

    View full-size slide

  120. @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

    View full-size slide

  121. @holly_cummins #RedHat
    what about memory?
    more complete model:


    both throughput (execution time) and memory
    contribute to carbon footprint

    View full-size slide

  122. @holly_cummins #RedHat
    what about memory?
    more complete model:


    both throughput (execution time) and memory
    contribute to carbon footprint
    quarkus is most efficient for


    • startup time


    • throughput


    • memory (RSS size)

    View full-size slide

  123. @holly_cummins #RedHat
    trick 5: use quarkus

    View full-size slide

  124. @holly_cummins #RedHat
    trick 5: use quarkus
    quarkus ‘automatically’ saves

    View full-size slide

  125. @holly_cummins #RedHat
    trick 5: use quarkus
    quarkus ‘automatically’ saves
    • time

    View full-size slide

  126. @holly_cummins #RedHat
    trick 5: use quarkus
    quarkus ‘automatically’ saves
    • time
    • money

    View full-size slide

  127. @holly_cummins #RedHat
    trick 5: use quarkus
    quarkus ‘automatically’ saves
    • time
    • money
    • carbon (~2x)

    View full-size slide

  128. @holly_cummins #RedHat
    trick 5: use quarkus
    quarkus ‘automatically’ saves
    • time
    • money
    • carbon (~2x)
    • … even when Spring compatibility libraries are used
    (almost no code changes except dependencies and tests)

    View full-size slide

  129. @holly_cummins #RedHat
    trick 5: use quarkus
    quarkus ‘automatically’ saves
    • time
    • money
    • carbon (~2x)
    • … even when Spring compatibility libraries are used
    (almost no code changes except dependencies and tests)

    View full-size slide

  130. @holly_cummins #RedHat
    aaaaaaaargh?

    View full-size slide

  131. @holly_cummins #RedHat
    carbon
    awareness
    hardware
    efficiency
    electricity
    efficiency
    green software foundation: principles
    utility

    View full-size slide

  132. @holly_cummins #RedHat
    is using this carbon giving value?
    utility

    View full-size slide

  133. @holly_cummins #RedHat
    “no-regrets” solutions

    View full-size slide

  134. @holly_cummins
    #RedHat

    View full-size slide

  135. @holly_cummins
    #RedHat
    co-benefits

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  142. @holly_cummins #RedHat
    climate solutions can
    make everything better

    View full-size slide

  143. @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

    View full-size slide

  144. @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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  149. @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

    View full-size slide

  150. @holly_cummins #RedHat
    remember the vrrrrrooooooooom model?
    (probably not, it was a made-up name)

    View full-size slide

  151. @holly_cummins #RedHat
    we need a new mental model for ‘virtuous’
    car:


    high max speed means high fuel
    usage per mile travelled

    View full-size slide

  152. @holly_cummins #RedHat
    software:


    high max transactions means
    low carbon per transaction
    we need a new mental model for ‘virtuous’
    car:


    high max speed means high fuel
    usage per mile travelled

    View full-size slide

  153. @holly_cummins #RedHat
    the double-win

    View full-size slide

  154. @holly_cummins #RedHat
    the double-win

    View full-size slide

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


    – Dr. Jonathan Foley

    View full-size slide

  156. @holly_cummins #RedHat
    tl;dpa


    (too long; didn’t pay attention)
    trick 1: choose your hosting wisely


    trick 2: architect to be able to turn stuff off
    (LightSwitchOps)


    trick 3: the vrrrooooom model says faster is greener


    trick 4: the economic model says cheaper is greener


    trick 5: choose a fast and energy-efficient framework,
    such as quarkus

    View full-size slide

  157. @holly_cummins #RedHat
    we all make a difference

    View full-size slide