This project comes with a performance testing script ngxway_benchmark
that provides observation indicators such as QPS, time consumption, memory usage, and CPU usage.
ab tool
. If the ab tool
is not installed on your machine, please install the ab tool first.在启动本项目后,使用以下命令即可开始性能测试。
bash bin/ngxway_benchmark api
When starting, ngxway_benchmark
will perform the following 14 test cases by default on the current machine:
n 10000 -c 32
: 32 concurrent requests, completing a total of 10,000 requests and endingn 10000 -c 64
: 64 concurrent requests, completing a total of 10,000 requests and endingn 10000 -c 128
: 128 concurrent requests, completing a total of 10,000 requests and endingn 10000 -c 256
: 256 concurrent requests, completing a total of 10,000 requests and endingn 10000 -c 512
: 512 concurrent requests, completing a total of 10,000 requests and endingn 10000 -c 1024
: 1024 concurrent requests, completing a total of 10,000 requests and endingn 10000 -c 1200
: 1200 concurrent requests, completing a total of 10,000 requests and endingn 100000 -c 32
: 32 concurrent requests, completing a total of 100,000 requests and endingn 100000 -c 64
: 64 concurrent requests, completing a total of 100,000 requests and endingn 100000 -c 128
: 128 concurrent requests, completing a total of 100,000 requests and endingn 100000 -c 256
: 256 concurrent requests, completing a total of 100,000 requests and endingn 100000 -c 512
: 512 concurrent requests, completing a total of 100,000 requests and endingn 100000 -c 1024
: 1024 concurrent requests, completing a total of 100,000 requests and endingn 100000 -c 1200
: 1200 concurrent requests, completing a total of 100,000 requests and ending
During the process, the command will also display real-time stress test information.After completing the test, the system will generate a test report file named {NGXWAY_BASE_PATH}/logs/benchmark.html
in the logs
folder of the project root directory.
When you operate on a Mac system, the system automatically opens the test report in the Chrome browser. If your system is not a Mac or the test report fails to open normally, you can open it manually to view.
On an 8C16G
machine, without any additional optimizations, the QPS of the ngxway gateway service fluctuated between 30,000 to 60,000
, with an average of 50,000
.
In addition to testing the performance of ngxway, several performance comparisons were also conducted, with the following conclusions: In addition to testing the performance of ngxway, multiple performance comparisons were conducted on three different clean versions (without any modifications or optimizations) of the “goserver”, “nginx”, and “openresty” services under the “/example/” directory. The following conclusions were mainly drawn.
Under the same testing conditions, the ratio of QPS measured for ngxway, nginx, and openresty was “1:0.6:0.3”.
Under the same testing conditions, ngxway’s performance is approximately 50%~70%
of the go test API performance. This means that if the QPS of the go test API on your machine can reach 100,000
, then ngxway can reach a QPS of 50,000~70,000
.
The bridge
network mode of Docker results in an additional performance loss of around 30%
for the service. Therefore, if you aim for higher performance, please set docker_network
to host
mode in the ngxway.conf
configuration file. Please note that the “host” mode cannot be used on Mac systems.