Slide 1

Slide 1 text

Thomas Vitale Maersk May 4th, 2023 Observability and Efficiency with Spring Boot 3 @vitalethomas

Slide 2

Slide 2 text

Systematic • Software Engineer and Cloud Architect. • Author of “Cloud Native Spring in Action” (Manning). • OSS contributor (Java, Spring, Cloud Native Technologies) Thomas Vitale thomasvitale.com @vitalethomas

Slide 3

Slide 3 text

Spring @vitalethomas

Slide 4

Slide 4 text

thomasvitale.com @vitalethomas https://spring.io @vitalethomas

Slide 5

Slide 5 text

Java 17 @vitalethomas

Slide 6

Slide 6 text

Java 8 -> 11 -> 17 Performance improvements @vitalethomas Java 8 ‣Startup: 3.784 s ‣Max heap used: 113 MiB ‣Committed heap: 177 MiB Java 11 ‣Startup: 2.204 s ‣Max heap used: 43 MiB ‣Committed heap: 74 MiB Java 17 ‣Startup: 1.776 s ‣Max heap used: 37 MiB ‣Committed heap: 55 MiB

Slide 7

Slide 7 text

Deployment @vitalethomas

Slide 8

Slide 8 text

Packaging Spring Boot JAR & Container Image JAR Container Image Gradle bootJar Maven spring-boot:repackage Gradle bootBuildImage Maven spring-boot:build-image @vitalethomas

Slide 9

Slide 9 text

Image pack build Cloud Native Buildpacks From source code to container image @vitalethomas

Slide 10

Slide 10 text

Native Images @vitalethomas

Slide 11

Slide 11 text

Spring Boot 3 and Native Images Native executables with GraalVM Slower Heavier Build Instant Startup Reduced Memory Consumption Instant Peak Performance Fewer Runtime Optimizations @vitalethomas

Slide 12

Slide 12 text

Data Persistence @vitalethomas

Slide 13

Slide 13 text

Data Integration Spring Data for Relational Databases Spring Data JPA ‣JPA & Hibernate ‣Repositories ‣JDBC Spring Data JDBC ‣DDD Principles ‣Repositories ‣JDBC Spring Data R2DBC ‣DDD Principles ‣Repositories ‣R2DBC @vitalethomas

Slide 14

Slide 14 text

Data Integration Spring Data for Relational Databases Spring Data JPA ‣JPA & Hibernate ‣Repositories ‣JDBC Spring Data Relational ‣DDD Principles ‣Repositories ‣JDBC/R2DBC @vitalethomas

Slide 15

Slide 15 text

Schema and data management Flyway: Version control for your database SQL Migrations Schema changes Java Migrations Data changes V1 Init schema V2 Add column V3 Create table V4 Add constraint time @vitalethomas

Slide 16

Slide 16 text

Testing @vitalethomas

Slide 17

Slide 17 text

Testing Spring Boot Types of auto tests for Spring Boot applications Unit Tests ‣JUnit ‣Mockito ‣No Spring context Integration Tests ‣@SpringBootTest ‣Web server ‣Full Spring context Slice Tests ‣@SpringWebMvc ‣@SpringDataR2dbc ‣Sliced Spring context @vitalethomas

Slide 18

Slide 18 text

Testcontainers Testing with external dependencies OCI containers Run external dependencies as OCI containers Data Layer Tests Ensure environment parity by testing the data layer with the real database Integration Tests Use containers for databases, message queues, and web servers @vitalethomas

Slide 19

Slide 19 text

Jakarta EE 9/10 @vitalethomas

Slide 20

Slide 20 text

From Java EE to Jakarta EE New package names since Jakarta EE 9 import javax.persistence.Entity; import javax.servlet.Servlet; import javax.validation.Valid; @vitalethomas import jakarta.persistence.Entity; import jakarta.servlet.Servlet; import jakarta.validation.Valid;

Slide 21

Slide 21 text

https://docs.openrewrite.org @vitalethomas

Slide 22

Slide 22 text

Problem Details @vitalethomas

Slide 23

Slide 23 text

https://www.rfc-editor.org/rfc/rfc7807 @vitalethomas

Slide 24

Slide 24 text

Declarative Clients @vitalethomas

Slide 25

Slide 25 text

Observability @vitalethomas

Slide 26

Slide 26 text

Monitoring and management Operating applications in production Spring Boot Actuator ‣Health (liveness and readiness) ‣Metrics (Prometheus, OpenMetrics) ‣Flyway, Thread Dumps, Heap Dumps Micrometer Tracing ‣Distributed tracing ‣Instrumentation ‣OpenZipkin and OpenTelemetry @vitalethomas

Slide 27

Slide 27 text

grafana.com @vitalethomas

Slide 28

Slide 28 text

https://github.com/paketo-buildpacks/opentelemetry @vitalethomas

Slide 29

Slide 29 text

https://github.com/paketo-buildpacks/samples/tree/main/java/opentelemetry @vitalethomas tasks.named('bootBuildImage') { buildpacks = [ "paketo-buildpacks/java", "gcr.io/paketo-buildpacks/opentelemetry" ] environment = ["BP_OPENTELEMETRY_ENABLED": "true"] } OpenTelemetry Support in Paketo Buildpacks

Slide 30

Slide 30 text

Resources @vitalethomas

Slide 31

Slide 31 text

https://github.com/ThomasVitale/spring-boot-next-gen-apps

Slide 32

Slide 32 text

https://github.com/ThomasVitale/awesome-spring

Slide 33

Slide 33 text

Thomas Vitale Maersk May 4th, 2023 Observability and Efficiency with Spring Boot 3 @vitalethomas