一個簡易,而且高性能的測試工具。以前使用的是ab,但發現envoy默認不支持http 1.0,而ab目前只支持http 1.0,因此完美的錯開了。envoy是能夠支持http 1.0的,可是我配置了下,好像沒有成功,就沒有深刻了,果斷換了wrk,目前使用起來感受這個工具很好用。html
wkr通常線程數不宜過多, 核數的2到4倍足夠了, 多了反而由於線程切換過多形成效率下降, 由於 wrk 不是使用每一個鏈接一個線程的模型, 而是經過異步網絡 io 提高併發量. 因此網絡通訊不會阻塞線程執行,這也是 wrk 能夠用不多的線程模擬大量網路鏈接的緣由。 而如今不少性能工具並無採用這種方式, 而是採用提升線程數來實現高併發, 因此併發量一旦設的很高, 測試機自身壓力就很大, 測試效果反而降低。git
安裝參考github
refer:
https://www.cnblogs.com/xinzh...
命令行:docker
wrk -t100 -c10000 -d60s --timeout 60s http://ambassador.default.svc...:80/http-echo/
[root@master01 ambassador]# wrk Usage: wrk <options> <url> Options: -c, --connections <N> Connections to keep open -d, --duration <T> Duration of test -t, --threads <N> Number of threads to use -s, --script <S> Load Lua script file -H, --header <H> Add header to request --latency Print latency statistics --timeout <T> Socket/request timeout -v, --version Print version details Numeric arguments may include a SI unit (1k, 1M, 1G) Time arguments may include a time unit (2s, 2m, 2h)
後臺服務爲go寫的http server,參考: https://github.com/hashicorp/...api
--- apiVersion: v1 kind: Service metadata: name: http-echo annotations: getambassador.io/config: | --- apiVersion: ambassador/v0 kind: Mapping name: httpecho_mapping prefix: /http-echo/ service: http-echo spec: selector: app: http-echo ports: - port: 80 name: http-echo targetPort: 5678 --- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: http-echo spec: replicas: 6 strategy: type: RollingUpdate template: metadata: labels: app: http-echo spec: containers: - name: http-echo image: hashicorp/http-echo args: ["-text=\"hello world\""] ports: - name: httpa containerPort: 5678 resources: limits: cpu: "1" memory: 512Mi
component | version | |
---|---|---|
docker | 1.13.1 | |
k8s | 1.15.2 | |
ambassador | 0.83.0 | |
envoy | 1.12.0 |
component | replica | resource | |
---|---|---|---|
http-echo | 3副本 | 1C1G | |
ambassador | 10副本 | 2C0.5G |
wrk -t100 -c10000 -d60s --timeout 60s http://http-echo.default.svc....:80
wrk -t100 -c1000 -d60s --timeout 60s http://ambassador.default.svc...:80/http-echo/
method | concurrency | time | rqs | transfer/sec | latency avg | latency max | latency std |
---|---|---|---|---|---|---|---|
service | 1000 | 1st | 53709.17 | 9.01MB | 31.36ms | 689.04ms | 80.48% |
service | 1000 | 2nd | 53452.36 | 8.97MB | 31.55ms | 497.89ms | 80.89% |
service | 10000 | 1st | 59413.33 | 9.97MB | 225.50ms | 6.90s | 91.98% |
service | 10000 | 2nd | 59920.76 | 10.06MB | 223.60ms | 8.71s | 92.36% |
ambassador | 1000 | 1st | 30484.25 | 6.55MB | 38.44ms | 367.21ms | 68.18% |
ambassador | 1000 | 2nd | 30688.21 | 6.59MB | 38.30ms | 304.27ms | 67.30% |
ambassador | 10000 | 1st | 30512.20 | 6.59MB | 335.20ms | 4.24s | 70.35% |
ambassador | 10000 | 2nd | 30977.12 | 6.69MB | 336.08ms | 3.69s | 71.70% |