Code Monkey home page Code Monkey logo

spring-virtual-thread-test's Introduction

Spring Virtual Thread Test

Read the article on the comparison between Reactive and Virtual Thread and find out who won:
https://www.vincenzoracca.com/en/blog/framework/spring/virtual-threads-vs-webflux/

Postgres 15 on Amazon Linux 23

https://linux.how2shout.com/how-to-install-postgresql-15-amazon-linux-2023/
https://stackoverflow.com/questions/74110708/postgres-15-permission-denied-for-schema-public

and add this: host all all 0.0.0.0/0 md5
in /var/lib/pgsql/data/pg_hba.conf.

Jmeter file

Jmeter file

Command to run reactive app

nohup java    -Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=1099 \
-Dcom.sun.management.jmxremote.rmi.port=1099 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.local.only=false \
-Djava.rmi.server.hostname=<ip> \
-Dspring.r2dbc.username=myuser \
-Dspring.r2dbc.password=secret \
-Dspring.r2dbc.url=r2dbc:postgresql://<ip_pg>:5432/mydatabase \
-Dcustom.mockclient-url=<url_mock_client> \
-jar spring-virtual-thread-test/reactive/target/reactive-0.0.1-SNAPSHOT.jar &

Command to run vt app

nohup java    -Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=1099 \
-Dcom.sun.management.jmxremote.rmi.port=1099 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.local.only=false \
-Djava.rmi.server.hostname=<ip> \
-Dspring.datasource.username=myuser \
-Dspring.datasource.password=secret \
-Dspring.datasource.url=jdbc:postgresql://<ip_pg>:5432/mydatabase \
-Dcustom.mockclient-url=<url_mock_client> \
-jar spring-virtual-thread-test/virtual-threads/target/virtual-threads-0.0.1-SNAPSHOT.jar &

Test with reactive native image (using GRAALVM)

Run Docker image:

cd reactive
./mvnw clean spring-boot:build-image -DskipTests
docker run --name reactive -p8080:8080 -p1099:1099 \
-e SPRING_R2DBC_USERNAME=myuser -eSPRING_R2DBC_PASSWORD=secret \
-e SPRING_R2DBC_URL=r2dbc:postgresql://<ip_pg>:5432/mydatabase \
-e CUSTOM_MOCKCLIENT_URL=<url_mock_client> \
-e JAVA_TOOL_OPTIONS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.rmi.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=<ip>" \
-d reactive:0.0.1-SNAPSHOT

Build native app:

cd reactive
./mvnw -Pnative clean native:compile -DskipTests
cd target
./reactive -Dspring.r2dbc.url=r2dbc:postgresql://<ip_pg>:5432/mydatabase \
 -Dspring.r2dbc.username=myuser -Dspring.r2dbc.password=secret -Dspring.sql.init.mode=never
 -Dcom.sun.management.jmxremote.port=1099 \
 -Dcom.sun.management.jmxremote.rmi.port=1099 \
 -Dcom.sun.management.jmxremote.ssl=false \
 -Dcom.sun.management.jmxremote.authenticate=false \
 -Dcom.sun.management.jmxremote.local.only=false \
 -Djava.rmi.server.hostname=<ip>

Build native image:

cd reactive
./mvnw clean spring-boot:build-image -DskipTests -Pnative

Run native image:

docker run --name reactive -p8080:8080 -p1099:1099 \
-e SPRING_R2DBC_USERNAME=myuser -eSPRING_R2DBC_PASSWORD=secret \
-e SPRING_R2DBC_URL=r2dbc:postgresql://<ip_pg>:5432/mydatabase \
-e CUSTOM_MOCKCLIENT_URL=<url_mock_client> \
-d reactive:0.0.1-SNAPSHOT -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.rmi.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=<ip>

Issues encountered:

  1. spring-attic/spring-native#1470
  2. https://docs.spring.io/spring-framework/docs/6.0.0/reference/html/core.html#aot-hints-register-reflection-for-binding https://docs.spring.io/spring-framework/docs/6.0.0/reference/html/core.html#aot-hints-register-reflection-for-binding 2024-01-14T14:50:10.320Z WARN 1 --- [or-http-epoll-5] r.netty.http.client.HttpClientConnect : [c75f04e4-1, L:/172.17.0.4:45894 - R:host.docker.internal/192.168.65.254:8092] The connection observed an error org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type '' not supported for bodyType=com.vincenzoracca.reactive.model.NameDTO

spring-virtual-thread-test's People

Contributors

vincenzo-racca avatar vincenzo-racca-pa avatar

Stargazers

Omar Gomaa avatar yunlongn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.