Sustainability

software / architecture / platforms

Agenda

  • Sustainability
  • Software
  • Architecture
  • Platforms

Bill

Career

  • 32% // Solutions Engineering
  • 60% // Systems Architecture
  • 5% // Wireless Spectrum Research
  • 3% // Embedded Sofware Development

πŸ“· Photographer ・ πŸ‘¨β€πŸ‘©β€πŸ‘¦β€πŸ‘¦ Father ・ πŸ‡¨πŸ‡³ Mandarin Learner

πŸ€“ Self-Hoster ・ πŸ‘¨β€πŸ’» Go Developer ・ πŸ“ Letter Writer

🏠 London ・ πŸ—ΊοΈ China

Contact

πŸ‘¨β€πŸ’» bill.dev
πŸ—“οΈ meet.bill.dev

Sustainability

Sustainability

“meeting the needs of the present without compromising the ability of future generations to meet their own needs.”

Sustainability

“Resource efficiency means using the Earth’s limited resources in a sustainable manner while minimising environmental impacts. It allows us to create more with less and to deliver greater value with less input.”

Practically Speaking

  • Create real value (for now and the future)
  • Use only what’s needed, and no more.

Why should you care?

🌍

πŸ’Έ

But I write code

Metric Value (2024-2025)
Data centre electricity consumption ~415–500 TWh
Share of total electricity consumption ~1.5%
Projected 2030 consumption ~945 TWh
Drivers for growth AI workloads, cloud, crypto

Source: iea.org

  • Industrialisation & cheap energy
  • Moore’s Law
  • Globalisation
  • Always on, always connected
  • Infrastructure as code
  • Fast response times
  • Big data, analytics

Software Development Lifecycle

tool-calling_001.png

Sustainability Throughout

  • idea
  • development
  • iteration
  • test
  • runtime
  • decommission

Three Things

  1. Spring
  2. Architecture
  3. Cloud Foundry

One Caveat

All apps are different

1. Spring

Spring continues to evolve

Spring Boot requires at least Java 17

spring.io

As does Java

8 β†’ 11 β†’ 17 β†’ 21 β†’ 25


Learn More

What can we optimise for?

  • Startup – scale to zero
  • Memory – more apps on fewer servers
  • Warmup – reach peak performance faster
  • Utilisation – get the most out of hardware

Spring Boot 2.7.3 and Java 8

sdk use java 8.0.452-librca
./mvnw clean package -DskipTests
java -jar target/spring-petclinic-2.7.3.jar

metric value
application.started.time 2.777s
jvm.memory.used 425482804 bytes

Upgrade JDK / JVM to Java 24

sdk use java 24.0.1-librca
./mvnw clean package -DskipTests
java -jar target/spring-petclinic-2.7.3.jar

metric value
application.started.time 2.967s
jvm.memory.used 180627216 bytes

Use Java 24 and Spring Boot 3.5.0

git checkout 3.5.0
sdk use java 24.0.1-librca
./mvnw clean package -DskipTests
java -jar target/spring-petclinic-2.7.3.jar

metric value
application.started.time 2.614s
jvm.memory.used 317451088 bytes

Use Java 24 and Spring Boot 3.5.0 - Extracted

git checkout 3.5.0
sdk use java 24.0.1-librca
./mvnw clean package -DskipTests
java -Djarmode=tools \
  -jar target/spring-petclinic-3.5.0-SNAPSHOT.jar \
	extract --destination application
java -jar application/spring-petclinic-3.5.0-SNAPSHOT.jar

metric value
application.started.time 2.152s
jvm.memory.used 185253504 bytes

Use Virtual Threads

spring.threads.virtual.enabled=true

Class Data Sharing (CDS)

java -XX:ArchiveClassesAtExit=application.jsa \
	-Dspring.context.exit=onRefresh \
	-jar application/spring-petclinic-3.5.0-SNAPSHOT.jar
java -XX:SharedArchiveFile=application.jsa \
-jar application/spring-petclinic-3.5.0-SNAPSHOT.jar

metric value
application.started.time 1.194s
jvm.memory.used 299730896 bytes

Use Spring AOT

java -Djarmode=tools \
  -jar target/spring-petclinic-3.5.0-SNAPSHOT.jar \
  extract --destination application
java -Dspring.aot.enabled=true \
  -jar application/spring-petclinic-3.5.0-SNAPSHOT.jar

metric value
application.started.time 1.917s
jvm.memory.used 184700336 bytes

Use GraalVM for Native Image Building

sdk use java 24.0.1-graalce
./mvnw -q -Pnative clean native:compile \
  -DskipTests -Dcheckstyle.skip
./target/spring-petclinic

metric value
application.started.time 0.204s
jvm.memory.used 44695592 bytes

2. Architecture

Multi-Site Architecture

Long tail

  • 20% of your APIs handle 80% of the traffic
  • 80% sit idle the majority of the time

Multi-Site Architecture

The curse of non-functional side-effects

  • “must be deployed in both sites”
  • “must have three instances”
  • “must respond within [fast]ms”

Missing?

Must do all the above while minimising environmental footprint

Multi-Site Architecture Scale to Zero a

Multi-Site Architecture Scale to Zero b

Multi-Site Architecture Scale to Zero a

scale to zero

*not currently in Cloud Foundry

3. Cloud Foundry

🦸

Multi-Tenancy

Puzzle Pieces

  1. Foundation
  2. Org
  3. Space
  4. Isolation Segment

Foundation

Multi-Tenancy Foundations

Org

Multi-Tenancy Orgs

Space

Multi-Tenancy Spaces

Isolation Segment

Multi-Tenancy Isolation Segments

CF

22 Foundations
2800 VMs

k8s

1000 Clusters
3000 VMs (control plane)

Small Footprint

New Upgrade to full foundations!
Idea Reduced minimum install footprint

Three Things

  1. Spring βœ…
  2. Architecture βœ…
  3. Cloud Foundry βœ…

🎀

Thank you!

πŸ‘¨β€πŸ’» bill.dev
πŸ—“οΈ meet.bill.dev