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

Next-Generation Cloud Native Apps with Spring Boot 3

Next-Generation Cloud Native Apps with Spring Boot 3

The recent release of Spring Boot 3 laid the foundation for the next generation of modern Java applications. This session will highlight what’s new, and demonstrate hands-on patterns and techniques for cloud native development.

Support for generating native executables with GraalVM is now part of the core framework, making it straightforward to build efficient applications with instant startup time and reduced memory consumption. The new Java 17 baseline and support for Jakarta EE 10 unlock many new features and integrations.

Observability is now a core tenet of the Spring ecosystem, with monitoring and tracing built into each Spring module and powered by Micrometer and OpenTelemetry. Finally, developer experience gets a significant boost with the new development services based on Docker Compose and Testcontainers.

Thomas Vitale

May 23, 2023
Tweet

More Decks by Thomas Vitale

Other Decks in Technology

Transcript

  1. Thomas Vitale
    GOTO Aarhus
    May 23rd, 2023
    Next-Generation
    Cloud Native Apps
    with Spring Boot 3
    @vitalethomas

    View 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 Slide

  3. Spring
    @vitalethomas

    View Slide

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

    View Slide

  5. Java 17
    @vitalethomas

    View 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 Slide

  7. Deployment
    @vitalethomas

    View 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 Slide

  9. “Friends don’t let friends write Dockerfiles!”
    - Josh Long
    @vitalethomas

    View Slide

  10. Dockerfiles
    “Dockerfiles are easy to write, but the current
    development guidelines do not produce
    containers that are repeatable and hardened.”

    CNCF Software Supply Chain Security Paper
    https://github.com/cncf/tag-security/tree/main/supply-chain-security
    @vitalethomas

    View Slide

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

    View Slide

  12. Native Images
    @vitalethomas

    View Slide

  13. Spring Boot 3 and Native Executables
    The bene
    fi
    ts of GraalVM
    Instant

    Startup
    Low

    Resource

    Usage
    Instant

    Peak

    Performance
    @vitalethomas
    Reduced

    Surface

    Attack
    Compact

    Packaging

    View Slide

  14. Spring Boot 3 and Native Executables
    The downsides of GraalVM
    Slower

    Heavier

    Build
    Additional
    con
    fi
    guration
    might be
    needed
    @vitalethomas

    View Slide

  15. Data Persistence
    @vitalethomas

    View Slide

  16. 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 Slide

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


    ‣Repositories


    ‣JDBC
    Spring Data Relational
    ‣DDD Principles


    ‣Repositories


    ‣JDBC/R2DBC
    @vitalethomas

    View Slide

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

  19. Testing
    @vitalethomas

    View Slide

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

  21. Testcontainers
    Development and 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 Slide

  22. Jakarta EE 10
    @vitalethomas

    View Slide

  23. 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 Slide

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

    View Slide

  25. Observability
    @vitalethomas

    View Slide

  26. Spring Observability
    Production-grade features
    Spring Boot Actuator
    ‣Health (liveness and readiness)


    ‣Metrics (Prometheus, OpenMetrics)


    ‣Flyway, Thread Dumps, Heap Dumps
    Micrometer
    ‣Uni
    fi
    ed Observation API


    ‣Instrumentation for metrics and traces


    ‣OpenZipkin, OpenTelemetry
    @vitalethomas

    View Slide

  27. grafana.com @vitalethomas

    View Slide

  28. Declarative Clients
    @vitalethomas

    View Slide

  29. Problem Details
    @vitalethomas

    View Slide

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

    View Slide

  31. Resources
    @vitalethomas

    View Slide

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

    View Slide

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

    View Slide

  34. Thomas Vitale
    GOTO Aarhus
    May 23rd, 2023
    Next-Generation
    Cloud Native Apps
    with Spring Boot 3
    @vitalethomas

    View Slide