This is an automated email from the ASF dual-hosted git repository. spacewander pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push: new 8789cba70 docs: sync Chinese benchmark doc and add notes on running the benchmark (#7035) 8789cba70 is described below commit 8789cba70573dc3b44ae703ef4b2003148f890b6 Author: 云微 <1067852...@qq.com> AuthorDate: Tue May 17 10:35:01 2022 +0800 docs: sync Chinese benchmark doc and add notes on running the benchmark (#7035) --- docs/en/latest/benchmark.md | 14 +++++++++ docs/zh/latest/benchmark.md | 69 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/docs/en/latest/benchmark.md b/docs/en/latest/benchmark.md index c8e91f052..dc25c781d 100644 --- a/docs/en/latest/benchmark.md +++ b/docs/en/latest/benchmark.md @@ -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). + +::: diff --git a/docs/zh/latest/benchmark.md b/docs/zh/latest/benchmark.md index 0fa2bc8d0..d9bc3fc9b 100644 --- a/docs/zh/latest/benchmark.md +++ b/docs/zh/latest/benchmark.md @@ -49,6 +49,29 @@ title: 压力测试  +如果你需要在本地服务器上运行基准测试,你需要同时运行另一个 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: 压力测试 火焰图的采样结果:  + +如果你需要在本地服务器上运行基准测试,你需要同时运行另一个 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)。 + +:::