Skip to content

sdeleuze/petclinic-efficient-container

Repository files navigation

Spring Petclinic Efficient Container

This repository is designed to demonstrate how to improve Spring Boot applications efficiency and performances by upgrading from Spring Boot 2 / Java 8 to Spring Boot 3 / Java 21. This migration is done step by step and intermediate benchmarks can be performed.

Pre-requisites

If SDKMAN! is installed:

sdk env install

A recent version of Docker, Docker Compose should be installed.

Oha should be installed for benchmarks.

Getting started

If SDKMAN! is installed:

sdk env

To build the container image:

./build-container-image.sh

To run the application:

docker-compose up

Branches

Benchmarks

By default, benchmarks are done with 2 CPUs and 2G RAM in order to emulate a cheap Cloud instance (see related configuration in the docker-compose.yml file. Oha is used to benchmarks web endpoints with a 60s warmup and a 30s benchmark.

To benchmark a Thymeleaf template that is using cached data, run:

oha -z60s http://localhost:8080/vets.html && oha -z30s http://localhost:8080/vets.html

To benchmark a REST endpoint with JSON serialization using cached data, run:

oha -z60s http://localhost:8080/vets && oha -z30s http://localhost:8080/vets

To benchmark a Thymeleaf template that is using data retrieved by Spring Data JDBC, comment the @Cacheable("vets") annotation in VetRepository, rebuild and restart the container, then run:

oha -z60s http://localhost:8080/vets.html && oha -z30s http://localhost:8080/vets.html

To benchmark static resources, run:

oha -z60s http://localhost:8080/resources/images/spring-logo.png && oha -z30s http://localhost:8080/resources/images/spring-logo.png

About

Efficient containers with Spring Boot 3.3, Java 21, CDS and Virtual Threads

Resources

License

Stars

Watchers

Forks