这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos
sudo docker run \
--name postgres \
-p 5432:5432 \
-e POSTGRES_DB=quarkus_test \
-e POSTGRES_USER=quarkus \
-e POSTGRES_PASSWORD=123456 \
-d \
postgres:15
create table person (
id serial primary key,
name varchar(255),
gender varchar(255),
age int,
external_id int
);
insert into person(name, age, gender, external_id) values('John Smith', 25, 'MALE', 10);
insert into person(name, age, gender, external_id) values('Paul Walker', 65, 'MALE', 20);
insert into person(name, age, gender, external_id) values('Lewis Hamilton', 35, 'MALE', 30);
insert into person(name, age, gender, external_id) values('Veronica Jones', 20, 'FEMALE', 40);
insert into person(name, age, gender, external_id) values('Anne Brown', 60, 'FEMALE', 50);
insert into person(name, age, gender, external_id) values('Felicia Scott', 45, 'FEMALE', 60);
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=quarkus
quarkus.datasource.password=123456
quarkus.datasource.reactive.url=postgresql://192.168.0.99:5432/quarkus_test
sudo chmod a+r application.properties
docker run -idt \
--name quarkus \
-p 8080:8080 \
-v /home/lighthouse/config/quarkus/application.properties:/application/config/application.properties \
bolingcavalry/quarkus-virual-threads-demo:x64-0.0.3
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2022-10-16 11:46:41,406 INFO [io.quarkus] (main) quarkus-virual-threads-demo 1.0-SNAPSHOT on JVM (powered by Quarkus 2.13.2.Final) started in 0.804s. Listening on: http://0.0.0.0:8080
2022-10-16 11:46:41,414 INFO [io.quarkus] (main) Profile prod activated.
2022-10-16 11:46:41,414 INFO [io.quarkus] (main) Installed features: [cdi, reactive-pg-client, resteasy-reactive, resteasy-reactive-jackson, smallrye-context-propagation, vertx]
import http from 'k6/http';
import { sleep, check } from 'k6';
export let options = {
vus: 30,
duration: '60s',
};
export default function () {
let r = Math.floor(Math.random() * 6) + 1;
const res = http.get(`http://192.168.0.1:8080/vt/persons/${r}`);
check(res, {
'is status 200': (res) => res.status === 200,
'body size is > 0': (r) => r.body.length > 0,
});
sleep(1);
}
docker run --rm -i loadimpact/k6 run - < k6-vt-docker.js
import http from 'k6/http';
import { sleep, check } from 'k6';
export let options = {
vus: 30,
duration: '60s',
};
export default function () {
let r = Math.floor(Math.random() * 6) + 1;
const res = http.get(`http://192.168.0.1:8080/pool/persons/${r}`);
check(res, {
'is status 200': (res) => res.status === 200,
'body size is > 0': (r) => r.body.length > 0,
});
sleep(1);
}
sudo docker stop quarkus
spring.datasource.url=jdbc:postgresql://42.193.162.141:5432/quarkus_test
spring.datasource.username=quarkus
spring.datasource.password=123456
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.hbm2ddl.auto=update
spring.datasource.hikari.maximum-pool-size=256
sudo chmod a+r application.properties
docker run -idt \
--name springboot \
-p 8080:8080 \
-v /home/lighthouse/config/springboot/application.properties:/application/BOOT-INF/classes/application.properties \
bolingcavalry/springboot-postgresql-demo:x64-0.0.3
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.4)
2022-10-16 13:01:01.022 INFO 1 --- [ main] .b.s.SpringbootPostgresqlDemoApplication : Starting SpringbootPostgresqlDemoApplication v0.0.1-SNAPSHOT using Java 11.0.13 on 5c25db81639e with PID 1 (/application/BOOT-INF/classes started by root in /application)
2022-10-16 13:01:01.025 INFO 1 --- [ main] .b.s.SpringbootPostgresqlDemoApplication : No active profile set, falling back to 1 default profile: "default"
2022-10-16 13:01:01.795 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-10-16 13:01:01.857 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 47 ms. Found 1 JPA repository interfaces.
2022-10-16 13:01:02.392 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-10-16 13:01:02.405 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-10-16 13:01:02.405 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.65]
2022-10-16 13:01:02.492 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-10-16 13:01:02.492 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1364 ms
2022-10-16 13:01:02.701 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-10-16 13:01:02.741 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.11.Final
2022-10-16 13:01:02.867 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2022-10-16 13:01:02.942 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-10-16 13:01:03.164 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2022-10-16 13:01:03.179 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2022-10-16 13:01:03.688 INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-10-16 13:01:03.695 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
import http from 'k6/http';
import { sleep, check } from 'k6';
export let options = {
vus: 30,
duration: '60s',
};
export default function () {
let r = Math.floor(Math.random() * 6) + 1;
const res = http.get(`http://192.168.0.1:8080/springboot/persons/${r}`);
check(res, {
'is status 200': (res) => res.status === 200,
'body size is > 0': (r) => r.body.length > 0,
});
sleep(1);
}