mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-02 03:58:02 +08:00
docs: sync Chinese benchmark doc and add notes on running the benchmark (#7035)
This commit is contained in:
parent
3dddf41382
commit
8789cba705
@ -126,3 +126,17 @@ then run wrk:
|
||||
```shell
|
||||
wrk -d 60 --latency http://127.0.0.1:9080/hello
|
||||
```
|
||||
|
||||
For more reference on how to run the benchmark test, you can see this [PR](https://github.com/apache/apisix/pull/6136) and this [script](https://gist.github.com/membphis/137db97a4bf64d3653aa42f3e016bd01).
|
||||
|
||||
:::tip
|
||||
|
||||
If you want to run the benchmark with a large number of connections, You may have to update the **keepalive** config in the [conf/config-default.yaml](https://github.com/apache/apisix/blob/master/conf/config-default.yaml#L242). Connections exceeding this number will become short connections. You can run the following command to test the benchmark with a large number of connections:
|
||||
|
||||
```bash
|
||||
wrk -t200 -c5000 -d30s http://127.0.0.1:9080/hello
|
||||
```
|
||||
|
||||
For more details, you can refer to [Module ngx_http_upstream_module](http://nginx.org/en/docs/http/ngx_http_upstream_module.html).
|
||||
|
||||
:::
|
||||
|
@ -49,6 +49,29 @@ title: 压力测试
|
||||
|
||||
![flamegraph-1](../../assets/images/flamegraph-1.jpg)
|
||||
|
||||
如果你需要在本地服务器上运行基准测试,你需要同时运行另一个 NGINX 实例来监听 80 端口:
|
||||
|
||||
```bash
|
||||
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
|
||||
{
|
||||
"methods": ["GET"],
|
||||
"uri": "/hello",
|
||||
"upstream": {
|
||||
"type": "roundrobin",
|
||||
"nodes": {
|
||||
"127.0.0.1:80": 1,
|
||||
"127.0.0.2:80": 1
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
在完成配置并安装 [wrk](https://github.com/wg/wrk/) 之后,可以使用以下命令进行测试:
|
||||
|
||||
```bash
|
||||
wrk -d 60 --latency http://127.0.0.1:9080/hello
|
||||
```
|
||||
|
||||
### 测试反向代理,开启 2 个插件
|
||||
|
||||
我们把 APISIX 当做反向代理来使用,开启限速和 prometheus 插件,响应体的大小为 1KB。
|
||||
@ -69,3 +92,49 @@ title: 压力测试
|
||||
|
||||
火焰图的采样结果:
|
||||
![火焰图采样结果](../../assets/images/flamegraph-2.jpg)
|
||||
|
||||
如果你需要在本地服务器上运行基准测试,你需要同时运行另一个 NGINX 实例来监听 80 端口:
|
||||
|
||||
```bash
|
||||
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
|
||||
{
|
||||
"methods": ["GET"],
|
||||
"uri": "/hello",
|
||||
"plugins": {
|
||||
"limit-count": {
|
||||
"count": 999999999,
|
||||
"time_window": 60,
|
||||
"rejected_code": 503,
|
||||
"key": "remote_addr"
|
||||
},
|
||||
"prometheus":{}
|
||||
},
|
||||
"upstream": {
|
||||
"type": "roundrobin",
|
||||
"nodes": {
|
||||
"127.0.0.1:80": 1,
|
||||
"127.0.0.2:80": 1
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
在完成配置并安装 [wrk](https://github.com/wg/wrk/) 之后,可以使用以下命令进行测试:
|
||||
|
||||
```bash
|
||||
wrk -d 60 --latency http://127.0.0.1:9080/hello
|
||||
```
|
||||
|
||||
有关如何运行基准测试的更多参考,你可以查看此[PR](https://github.com/apache/apisix/pull/6136)和此[脚本](https://gist.github.com/membphis/137db97a4bf64d3653aa42f3e016bd01)。
|
||||
|
||||
:::tip
|
||||
|
||||
如果你想测试大量连接的基准测试,你可能需要更新 [`./conf/config-default.yaml`](https://github.com/apache/apisix/blob/master/conf/config-default.yaml#L242) 中的 **keepalive** 配置项,否则超过配置数量的连接将成为短连接。你可以使用以下命令运行大量连接的基准测试:
|
||||
|
||||
```bash
|
||||
wrk -t200 -c5000 -d30s http://127.0.0.1:9080/hello
|
||||
```
|
||||
|
||||
如果你需要了解更多信息,请参考:[ngx_http_upstream_module](http://nginx.org/en/docs/http/ngx_http_upstream_module.html)。
|
||||
|
||||
:::
|
||||
|
Loading…
Reference in New Issue
Block a user