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

Observability and Efficiency with Spring Boot 3

Observability and Efficiency with Spring Boot 3

Thomas Vitale

May 05, 2023
Tweet

More Decks by Thomas Vitale

Other Decks in Technology

Transcript

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

    View full-size slide

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

    View full-size slide

  3. Spring
    @vitalethomas

    View full-size slide

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

    View full-size slide

  5. Java 17
    @vitalethomas

    View full-size slide

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

    View full-size slide

  7. Deployment
    @vitalethomas

    View full-size slide

  8. Packaging Spring Boot
    JAR & Container Image
    JAR
    Container Image
    Gradle


    bootJar
    Maven


    spring-boot:repackage
    Gradle


    bootBuildImage
    Maven


    spring-boot:build-image
    @vitalethomas

    View full-size slide

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

    View full-size slide

  10. Native Images
    @vitalethomas

    View full-size slide

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

    View full-size slide

  12. Data Persistence
    @vitalethomas

    View full-size slide

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

    View full-size slide

  14. Data Integration
    Spring Data for Relational Databases
    Spring Data JPA
    ‣JPA & Hibernate


    ‣Repositories


    ‣JDBC
    Spring Data Relational
    ‣DDD Principles


    ‣Repositories


    ‣JDBC/R2DBC
    @vitalethomas

    View full-size slide

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

    View full-size slide

  16. Testing
    @vitalethomas

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  19. Jakarta EE 9/10
    @vitalethomas

    View full-size slide

  20. 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;

    View full-size slide

  21. https://docs.openrewrite.org @vitalethomas

    View full-size slide

  22. Problem Details
    @vitalethomas

    View full-size slide

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

    View full-size slide

  24. Declarative Clients
    @vitalethomas

    View full-size slide

  25. Observability
    @vitalethomas

    View full-size slide

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

    View full-size slide

  27. grafana.com @vitalethomas

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  30. Resources
    @vitalethomas

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide