Benchmark

Benchmark Environments

n1-highcpu-8 (8 vCPUs, 7.2 GB memory) on Google Cloud

But we only used 4 cores to run APISIX, and left 4 cores for system and wrk, which is the HTTP benchmarking tool.

Benchmark Test for reverse proxy

Only used APISIX as the reverse proxy server, with no logging, limit rate, or other plugins enabled, and the response size was 1KB.

QPS

The x-axis means the size of CPU core, and the y-axis is QPS.

benchmark-1

Latency

Note the y-axis latency in microsecond(μs) not millisecond.

latency-1

Flame Graph

The result of Flame Graph:

flamegraph-1

And if you want to run the benchmark test in your machine, you should run another Nginx to listen 80 port.

Benchmark - 图4note

You can fetch the admin_key from config.yaml and save to an environment variable with the following command:

  1. admin_key=$(yq '.deployment.admin.admin_key[0].key' conf/config.yaml | sed 's/"//g')
  1. curl http://127.0.0.1:9180/apisix/admin/routes/1 -H "X-API-KEY: $admin_key" -X PUT -d '
  2. {
  3. "methods": ["GET"],
  4. "uri": "/hello",
  5. "upstream": {
  6. "type": "roundrobin",
  7. "nodes": {
  8. "127.0.0.1:80": 1,
  9. "127.0.0.2:80": 1
  10. }
  11. }
  12. }'

then run wrk:

  1. wrk -d 60 --latency http://127.0.0.1:9080/hello

Benchmark Test for reverse proxy, enabled 2 plugins

Only used APISIX as the reverse proxy server, enabled the limit rate and prometheus plugins, and the response size was 1KB.

QPS

The x-axis means the size of CPU core, and the y-axis is QPS.

benchmark-2

Latency

Note the y-axis latency in microsecond(μs) not millisecond.

latency-2

Flame Graph

The result of Flame Graph:

flamegraph-2

And if you want to run the benchmark test in your machine, you should run another Nginx to listen 80 port.

  1. curl http://127.0.0.1:9180/apisix/admin/routes/1 -H "X-API-KEY: $admin_key" -X PUT -d '
  2. {
  3. "methods": ["GET"],
  4. "uri": "/hello",
  5. "plugins": {
  6. "limit-count": {
  7. "count": 999999999,
  8. "time_window": 60,
  9. "rejected_code": 503,
  10. "key": "remote_addr"
  11. },
  12. "prometheus":{}
  13. },
  14. "upstream": {
  15. "type": "roundrobin",
  16. "nodes": {
  17. "127.0.0.1:80": 1,
  18. "127.0.0.2:80": 1
  19. }
  20. }
  21. }'

then run wrk:

  1. 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 and this script.

Benchmark - 图8tip

If you want to run the benchmark with a large number of connections, You may have to update the keepalive config by adding the configuration to config.yaml and reload APISIX. Connections exceeding this number will become short connections. You can run the following command to test the benchmark with a large number of connections:

  1. wrk -t200 -c5000 -d30s http://127.0.0.1:9080/hello

For more details, you can refer to Module ngx_http_upstream_module.