Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
guanyang committed Oct 25, 2023
1 parent 293e2ef commit 957b5aa
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#### K6及dashboard安装
- k6安装,参考文档:https://k6.io/docs/get-started/installation/
- k6 dashboard安装,参考文档:https://github.com/grafana/xk6-dashboard
```

```text
1.Download xk6:
$> go install go.k6.io/xk6/cmd/xk6@latest
Expand All @@ -37,9 +38,11 @@ $> ./k6 run --out dashboard script.js
script: script.js
output: dashboard (:5665) http://127.0.0.1:5665
```

#### 压测脚本
- 总请求时长60s,并发从200开始,命令如下:
```

```text
k6 run --out dashboard=open -u 200 --duration 60s -e url=http://127.0.0.1:8081/hello/100 simple-test.js
-i:指定请求数量
Expand All @@ -48,8 +51,10 @@ k6 run --out dashboard=open -u 200 --duration 60s -e url=http://127.0.0.1:8081/h
-e url:指定环境变量url,用于实际场景替换
--out: 指定结果输出,例如:dashboard=open表示指定到k6 dashboard,并自动打开浏览器http://127.0.0.1:5665
```

#### `simple-test.js`脚本说明
```

```javascript
import http from 'k6/http';
import { check } from 'k6';

Expand Down Expand Up @@ -78,30 +83,38 @@ export default function () {
```

### 构建原生可执行文件

>示例工程:quarkus-sample,细节参考[构建quarkus原生可执行文件](https://cn.quarkus.io/guides/building-native-image)
- 方法一:如果本地已经安装`GraalVM`,则运行如下命令即可

```shell script
mvn clean package -DskipTests -Dnative
```
- 方法二:如果本地没有安装`GraalVM`,则运行如下命令,基于容器环境构建可执行文件,需要本地支持`docker`环境

```shell script
mvn clean package -DskipTests -Dnative -Dquarkus.native.container-build=true
```
- 以上命令将生成可执行文件: `./target/quarkus-sample-0.0.1-SNAPSHOT-runner`,直接运行即可。

### 构建容器镜像
- 方法一:使用容器镜像扩展,一个命令即可创建一个容器镜像,细节参考[容器镜像指南](https://cn.quarkus.io/guides/container-image)

```shell script
mvn clean package -Dnative -Dquarkus.native.container-build=true -Dquarkus.container-image.build=true
```

- 方法二:手动使用微基础镜像,细节参考[运行时基础镜像](https://cn.quarkus.io/guides/quarkus-runtime-base-image)

>如果你没有删除生成的原生可执行文件,可以用以下方法构建docker镜像:
```shell script
docker build -f src/main/docker/Dockerfile.native-micro -t guanyangsunlight/spring-project-samples:quarkus-sample-native-0.0.1 .
```

### 基于docker-compose运行quarkus-sample示例

```shell
docker-compose -p docker-quarkus-sample -f src/main/docker/docker-compose.yml up -d
```

0 comments on commit 957b5aa

Please sign in to comment.