Slide 1

Slide 1 text

Classification : Interne Design, Build, and Run Sustainable APIs and Softwares Thierno Diallo/ Staff Software Engineer @Axa France 03/11 to 05/11 – ApiDays 2024

Slide 2

Slide 2 text

Classification : Interne Green API/Software - What is Green API - Key points (Measurement, Green API Design principles, GreenCoding for implementation, and observability for continuous improvement) 2

Slide 3

Slide 3 text

Classification : Interne Measurement as First Step 1

Slide 4

Slide 4 text

Classification : Interne Measurement: Why Measure Energy/Carbon 4

Slide 5

Slide 5 text

Classification : Interne 5 Measurement: main mindsets

Slide 6

Slide 6 text

Classification : Interne 6 Measurement: tools overview 1/2 EcoCode https://github.com/green-code-initiative/ecoCode

Slide 7

Slide 7 text

Classification : Interne 7 Measurement: tools overview 2/2 Kepler https://github.com/sustainable-computing-io/kepler

Slide 8

Slide 8 text

Classification : Interne Green API Design Principles 2

Slide 9

Slide 9 text

Classification : Interne Energy-Efficient Design - Pattern: Lazy loading ▪ Best Practices: Stream API, @Lazy of Spring, Dynamic imports Next.js - Pattern: Optimize for low-latency ▪ Best Practices: Asynchronous Processing, CDN, API Endpoint Design 9

Slide 10

Slide 10 text

Classification : Interne Efficient Data Processing - Pattern: Cache && Memoization ▪ Best Practices: @Cachable Spring, useMemo Next.js, Redis - Pattern: Support delta updates ▪ Best Practices: Efficient Delta Calculation, Resource Change Tracking, Lightweight Data Representation - Pattern: Batch processing ▪ Best Practices: Chunk-oriented processing SpringBatch, Pagination, Bulk operations 10 API API API

Slide 11

Slide 11 text

Classification : Interne Optimize Network Traffic - Pattern: API Pagination ▪ Best Practices: Pageable Spring, Server-Side paginate Next.js, limit large database query - Pattern: Data Compression ▪ Best Practices: Enable data compression, Gzip Spring/Next.js, Brotli Next.js, large file compression - Pattern: Efficient protocols ▪ Best Practices: Enable HTTP/2 and 3, TLS, webSocket for real-time data/communication 11

Slide 12

Slide 12 text

Classification : Interne Resources Minimization - Pattern: Rate limiting ▪ Best Practices: Monitor/feedback requests, Dynamic rate ajustement - Pattern: Optimize database queries ▪ Best Practices: Index, database & query optimization, Denormalization and Caching - Pattern: Reduce the network resources requests to the lowest ▪ Best Practices: Efficient Data Fetching, Cache Utilization, Batch Requests 12

Slide 13

Slide 13 text

Classification : Interne Implementation with Green Coding 3

Slide 14

Slide 14 text

Classification : Interne Green Coding Principles: Code Efficiency - Pattern: Avoiding loops and repetitive operations ▪ Best Practices: Stream API, Data structures optimization, refact mapping and looping logic Next.js - Pattern: Object Pooling ▪ Best Practices: ObjectPool Design Pattern, DB Coonections Pooling, handling stateful object in React - Pattern: Code Duplication ▪ Best Practices: AOP Java/Spring, Shared Service, Analyse/Refactor Duplication 14

Slide 15

Slide 15 text

Classification : Interne Code Efficiency leitmotiv 15

Slide 16

Slide 16 text

Classification : Interne API Host and RUN with GreenOps 4

Slide 17

Slide 17 text

Classification : Interne Green Ops: Power Efficient Hosting - Pattern: Start/Expose APP on-demand ▪ Best Practices: Use DailyClean, SlimFaas - Pattern: Setup Only Infra Needed Resources ▪ Best Practices: monitor real resources need - Pattern: Auto-Scale (Kube context) ▪ Best Practices: Implement HPA, Resources limits and requests, Right size containers, Real time metrics 17

Slide 18

Slide 18 text

Classification : Interne Observability and Continuous Improvement As key mindset 5

Slide 19

Slide 19 text

Classification : Interne Observability ➔ 19

Slide 20

Slide 20 text

Classification : Interne Take Away 6

Slide 21

Slide 21 text

Classification : Interne Take Away: main messages - Every Step Toward efficiency count - Measurement, And continuous improvement is the key for success - Adopting Green API/Sofware Principles/Patterns and Practices is our ally - Leveraging Opensource 21

Slide 22

Slide 22 text

Classification : Interne Take Away: tools/resources sharing 22 1- AxaFrance/dailyclean: Save The planet by auto turn off your pods on kubernetes (github.com) 2- AxaFrance/SlimFaas: SlimFaas : The slimest and simplest Function As A Service (github.com) 3- Green-Software-Foundation/if: Impact Framework (github.com) 4- cnumr/ecoCode: Reduce the environmental footprint of applications with this sonarQube plugin 5- LightHouse-ecoIndex-Agregator Axa France (github.com) 6- Sustainable-computing-io/kepler: Kepler (Kubernetes-based Efficient Power Level Exporter)

Slide 23

Slide 23 text

Classification : Interne Call To Action 7

Slide 24

Slide 24 text

Classification : Interne Call To Action: We Need You - Be The Change ▪ Adopt Green By Design ▪ Adopt Green Coding practices - Start Small, Scale Big ▪ Join global conversation ▪ Learn from - Sustainable Code = Sustainable Future ▪ Commit to measuring and reducing 24

Slide 25

Slide 25 text

Classification : Interne Thanks « Together, we can code a greener future! » Thierno Diallo/ Staff Software Engineer @Axa France 03/11 to 05/11 – ApiDays 2024

Slide 26

Slide 26 text

Classification : Interne Thanks « Together, we can code a greener future! »