Slide 1

Slide 1 text

Thomas Vitale SpringOne Sep 1st, 2021 Spring Boot: Production Boost Boost your journey to production @vitalethomas

Slide 2

Slide 2 text

Thomas Vitale • Senior Software Engineer at Systematic, Denmark. • Spring, Cloud Native, DevOps, Kubernetes, Application Security. • Author of “Cloud Native Spring in Action” (Manning). About Me thomasvitale.com

Slide 3

Slide 3 text

thomasvitale.com @vitalethomas thomasvitale.com @vitalethomas JVM & Containers Data Integration Monitoring & Management Testing Con fi guration

Slide 4

Slide 4 text

Self-contained applications thomasvitale.com @vitalethomas JVM & Containers

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

Configuring Resources for JVM Containers CPU & Memory thomasvitale.com @vitalethomas CPU Memory When limit hit Throttle Compressible Resource When limit hit OOMKilled Non Compressible Resource

Slide 7

Slide 7 text

Database version control thomasvitale.com @vitalethomas Data Integration

Slide 8

Slide 8 text

Data Integration thomasvitale.com @vitalethomas 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 Data Integration

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

Externalized configuration thomasvitale.com @vitalethomas Con fi guration

Slide 11

Slide 11 text

Configuration Options thomasvitale.com @vitalethomas Spring Boot Properties ‣Property fi les ‣Command line arguments ‣Environment variables Con fi guration Services ‣Spring Cloud Con fi g Server ‣Spring Cloud Consul Con fi g ‣Spring Cloud Vault ‣Spring Cloud Zookeeper Con fi g Cloud Platform Services ‣Spring Cloud Alibaba ‣Spring Cloud AWS ‣Spring Cloud Azure ‣Spring Cloud GCP Kubernetes Platform ‣Con fi gMaps ‣Secrets ‣Environment variables Con fi guration

Slide 12

Slide 12 text

Configuration Strategies thomasvitale.com @vitalethomas Con fi guration Properties Property fi les ‣Default values ‣Development environment values Con fi guration Service Spring Cloud Con fi g ‣Connection pools ‣Timeouts and retries ‣Feature fl ags ‣External Services (URLs & Passwords) Kubernetes Platform Con fi gMaps & Secrets ‣Spring Active Pro fi les ‣Internal Services (URLs & Passwords) Con fi guration

Slide 13

Slide 13 text

ConfigMaps & Secrets thomasvitale.com @vitalethomas Mount the volume to the /config path, where Spring Boot will automatically read property fi les. Load the Con fi gMap In a volume

Slide 14

Slide 14 text

Environment Parity thomasvitale.com @vitalethomas Testing

Slide 15

Slide 15 text

Testing Spring Boot thomasvitale.com @vitalethomas 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 Testing

Slide 16

Slide 16 text

Testcontainers thomasvitale.com @vitalethomas Testing with external dependencies Docker containers Run external dependencies as Docker 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 Testing

Slide 17

Slide 17 text

Observable applications thomasvitale.com @vitalethomas Monitoring & Management

Slide 18

Slide 18 text

Monitoring and management thomasvitale.com @vitalethomas Operating applications in production Spring Boot Actuator ‣Health (liveness and readiness) ‣Metrics (Prometheus, OpenMetrics) ‣Flyway, Thread Dumps, Heap Dumps Spring Cloud Sleuth ‣Distributed tracing ‣Instrumentation ‣OpenZipkin and OpenTelemetry Monitoring & Management

Slide 19

Slide 19 text

Liveness and Readiness Probes thomasvitale.com @vitalethomas When not available, Kubernetes will restart the container When not ready, Kubernetes will not send any tra ff i c to the container

Slide 20

Slide 20 text

thomasvitale.com @vitalethomas thomasvitale.com @vitalethomas JVM & Containers Data Integration Monitoring & Management Testing Con fi guration

Slide 21

Slide 21 text

Thomas Vitale SpringOne Sep 1st, 2021 Spring Boot: Production Boost Boost your journey to production @vitalethomas