Virtual threads experiences
General information
This project aims to show what is the developer experience when the virtual threads are used, in comparison of the framework Reactor.
Therefore, there is one spring boot application which uses "standard java code" with virtual threads, and another spring boot application which uses Reactor.
Spring boot applications
Common concepts
Both applications are developed to serve same endpoints with same models.
Architecture
Both applications are architectured with a "light" version of the hexagonal architecture.
Java packages represent the hexagonal architecture modules:
- domain (Business code)
- exposition (Rest API)
- infrastructure (JPA layer)
Models
Exposed endpoints
- Catalogs
- GET /api/catalogs/{catalogId}
- Items
- GET /api/items
- POST /api/items
- Marketplace
- GET /api/marketplace
Virtual threads application
The application runs on port 51001.
./gradlew :virtual-threads-app:bootRun
Reactor application
The application runs on port 52001.
To start the application, run this command:
./gradlew :reactor-app:bootRun
Database
The database is a PostgreSQL database which runs inside a container.
To start the database, just run this command inside the project root folder:
docker compose up --detach --file ./docker-compose.yml
Then, you will have to initialise the tables by executing scripts located there into the container.
You can connect to it with this "unix" command:
docker exec --interactive --tty virtual-threads-test-db /bin/bash
psql --host localhost --port 5432 --username virtual_threads_test_user virtual_threads_test_db
Database files
There is a volumes for the database container, which points to this location: local/postgresql.
Bruno http client collection
There is a collection of queries, usable with bruno. It is located inside the rest-client-collection.
Load testing
Load tests use K6 framework.
Targeting the application to test
By default, tests are configured to load the virtual-threads-app.
If you want to run them on the reactor-app, you have to edit the variable TARGET_URL inside the file config.ts.
