Files
Florian THIERRY 5c6d54c459 Add documentation.
2025-10-09 17:54:36 +02:00

78 lines
2.4 KiB
Markdown

# 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
[<img src="./doc/images/models.png" witdh="1600px" />](./doc/images/models.png)
#### 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`.
```bash
./gradlew :virtual-threads-app:bootRun
```
### Reactor application
The application runs on port `52001`.
To start the application, run this command:
```bash
./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:
```bash
docker compose up --detach --file ./docker-compose.yml
```
Then, you will have to initialise the tables by executing scripts located [there](./src/main/sql/init_database.sql) into the container.
You can connect to it with this "unix" command:
```bash
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](./local/postgresql).
## Bruno http client collection
There is a collection of queries, usable with [bruno](https://www.usebruno.com/). It is located inside the [rest-client-collection](./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](./k6-load-tests/src/tests/config.ts).