$30 off During Our Annual Pro Sale. View Details »

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

June 21, 2023
Tweet

More Decks by Holly Cummins

Other Decks in Programming

Transcript

  1. 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

    View Slide

  2. @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 Slide

  3. @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 Slide

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

    View Slide

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

    View Slide

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

    View Slide

  7. @holly_cummins #RedHat
    aaaaaaaargh

    View Slide

  8. @holly_cummins #RedHat
    aaaaaaaargh?

    View Slide

  9. @holly_cummins #RedHat
    be a solutionist

    View Slide

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

    View Slide

  11. @holly_cummins #RedHat
    green software foundation: principles

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  21. @holly_cummins #RedHat
    algorithms


    stack
    carbon
    awareness
    hardware
    efficiency
    electricity
    efficiency
    where


    when
    elasticity


    utilisation
    green software foundation: principles

    View Slide

  22. @holly_cummins
    #RedHat
    efficiency

    View Slide

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

    View Slide

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

    View Slide

  25. View Slide

  26. energy efficiency
    of programming
    languages

    View Slide

  27. @holly_cummins
    #RedHat

    View Slide

  28. @holly_cummins
    #RedHat

    View Slide

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

    View Slide

  30. @holly_cummins #RedHat

    View Slide

  31. @holly_cummins #RedHat

    View Slide

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

    View Slide

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

    View Slide

  34. digression:


    measuring carbon is hard

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  43. @holly_cummins #RedHat

    View Slide

  44. @holly_cummins #RedHat

    View Slide

  45. @holly_cummins #RedHat

    View Slide

  46. @holly_cummins #RedHat
    load

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  53. @holly_cummins #RedHat
    simpler models

    View Slide

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

    View Slide

  55. @holly_cummins #RedHat
    trick 1: the vrrrrrooooooooom model*
    * a made-up name

    View Slide

  56. @holly_cummins
    #RedHat

    View Slide

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

    View Slide

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

    View Slide

  59. @holly_cummins #RedHat
    trick 2: the economic model*

    View Slide

  60. @holly_cummins #RedHat
    trick 2: the economic model*
    * "economic input-output life cycle assessment"

    View Slide

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

    View Slide

  62. so … quarkus?

    View Slide

  63. @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 Slide

  64. @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 Slide

  65. @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 Slide

  66. @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 Slide

  67. @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 Slide

  68. @holly_cummins #RedHat
    trick 3: use quarkus

    View Slide

  69. @holly_cummins #RedHat
    trick 3: use quarkus
    quarkus ‘automatically’ saves

    View Slide

  70. @holly_cummins #RedHat
    trick 3: use quarkus
    quarkus ‘automatically’ saves
    • time

    View Slide

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

    View Slide

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

    View Slide

  73. @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)

    View Slide

  74. @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)

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  78. @holly_cummins #RedHat
    application
    utilisation

    View Slide

  79. @holly_cummins #RedHat
    application
    utilisation
    high utilisation


    good case

    View Slide

  80. @holly_cummins #RedHat
    application
    utilisation
    over-utilisation


    very bad case

    View Slide

  81. @holly_cummins #RedHat
    application
    utilisation
    over-utilisation


    very bad case
    under-utilisation


    wasteful case

    View Slide

  82. @holly_cummins #RedHat
    application
    elasticity
    high utilisation


    good case
    @holly_cummins

    View Slide

  83. @holly_cummins #RedHat
    application
    elasticity
    scale-up


    good utilisation
    @holly_cummins

    View Slide

  84. @holly_cummins #RedHat
    application
    elasticity
    scale-down


    good utilisation
    @holly_cummins

    View Slide

  85. #RedHat
    @holly_cummins
    2017 server-survey


    25%


    doing no useful work


    (16,000 sampled)

    View Slide

  86. #RedHat
    @holly_cummins
    2017 server-survey


    25%


    doing no useful work


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

    View Slide

  87. #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 Slide

  88. @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 Slide

  89. @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 Slide

  90. @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 Slide

  91. @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 Slide

  92. @holly_cummins #RedHat
    it’s not just money

    View Slide

  93. @holly_cummins #RedHat
    it’s not just electricity
    it’s not just money

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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


    View Slide

  99. @holly_cummins
    #RedHat

    View Slide

  100. @holly_cummins
    #RedHat

    View Slide

  101. @holly_cummins
    #RedHat
    turning it off and on again must

    View Slide

  102. @holly_cummins
    #RedHat
    turning it off and on again must
    • be fast

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  111. @holly_cummins #RedHat

    View Slide

  112. @holly_cummins #RedHat
    backstage.io

    View Slide

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

    View Slide

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

    View Slide

  115. @holly_cummins #RedHat
    algorithms


    stack
    carbon
    awareness
    hardware
    efficiency
    electricity
    efficiency
    where


    when
    elasticity


    utilisation
    green software foundation: principles

    View Slide

  116. trick 5: electricity source

    View Slide

  117. @holly_cummins #RedHat
    data center location matters

    View Slide

  118. @holly_cummins #RedHat

    View Slide

  119. @holly_cummins #RedHat

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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


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

    View Slide

  124. @holly_cummins #RedHat
    aaaaaaaargh?

    View Slide

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

    View Slide

  126. @holly_cummins
    #RedHat

    View Slide

  127. @holly_cummins
    #RedHat
    co-benefits

    View Slide

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

    View Slide

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

    View Slide

  130. @holly_cummins
    #RedHat
    co-benefits
    the double win
    win-win
    twofer

    View Slide

  131. @holly_cummins
    #RedHat
    co-benefits
    the double win
    win-win
    twofer
    überwinden

    View Slide

  132. @holly_cummins
    #RedHat
    co-benefits
    the double win
    win-win
    twofer
    überwinden

    View Slide

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

    View Slide

  134. @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 Slide

  135. @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 Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  140. @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 Slide

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

    View Slide

  142. @holly_cummins #RedHat
    the double-win

    View Slide

  143. @holly_cummins #RedHat
    the double-win

    View Slide

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


    – Dr. Jonathan Foley

    View Slide

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

    View Slide

  146. @holly_cummins #RedHat
    we all make a difference

    View Slide

  147. slides
    thank you


    and don’t forget to vote in the J-Spring
    app, which is running on Quarkus :)


    @[email protected]

    View Slide