项目作者: linianhui

项目描述 :
http benchmark.
高级语言: Dockerfile
项目地址: git://github.com/linianhui/http.benchmark.git
创建时间: 2019-04-20T04:56:19Z
项目社区:https://github.com/linianhui/http.benchmark

开源协议:MIT License

下载


1 HTTP Benchmark 环境准备

监控 http://192.168.2.201:19999

1.1 准备2个HTTP服务器

  1. docker-compose up --detach --build
server port note
60001 http/1.1
60002 http/2 http2-prior-knowledge

验证是否成功启动

  1. curl --http1.1 -v http://192.168.2.201:60001
  2. curl --http2-prior-knowledge -v http://192.168.2.201:60002

1.2 准备1个HTTP客户端

  1. docker build --tag http-client ./client/

2 测试结果

HTTP/1.1 : docker run -it http-client h2load -c200 -n100000 --h1 http://192.168.2.201:60001

  1. finished in 6.47s, 15456.18 req/s, 12.42MB/s
  2. requests: 100000 total, 100000 started, 100000 done, 100000 succeeded, 0 failed, 0 errored, 0 timeout
  3. status codes: 100000 2xx, 0 3xx, 0 4xx, 0 5xx
  4. traffic: 80.35MB (84249000) total, 17.92MB (18795000) headers (space savings 0.00%), 58.36MB (61200000) data
  5. min max mean sd +/- sd
  6. time for request: 153us 73.38ms 12.78ms 4.51ms 72.82%
  7. time for connect: 29us 2.79ms 168us 477us 92.50%
  8. time to 1st byte: 8.65ms 30.75ms 19.81ms 4.82ms 67.00%
  9. req/s : 77.39 79.89 78.06 0.43 82.00%

HTTP/2 : docker run -it http-client h2load -c200 -n100000 -m100 http://192.168.2.201:60002

  1. finished in 3.55s, 28176.24 req/s, 19.86MB/s
  2. requests: 100000 total, 100000 started, 100000 done, 100000 succeeded, 0 failed, 0 errored, 0 timeout
  3. status codes: 100000 2xx, 0 3xx, 0 4xx, 0 5xx
  4. traffic: 70.49MB (73909800) total, 10.40MB (10900000) headers (space savings 38.76%), 58.36MB (61200000) data
  5. min max mean sd +/- sd
  6. time for request: 40.13ms 1.32s 632.70ms 161.49ms 77.65%
  7. time for connect: 6.27ms 61.61ms 27.21ms 10.12ms 78.00%
  8. time to 1st byte: 62.71ms 989.11ms 518.88ms 274.03ms 58.00%
  9. req/s : 140.88 172.80 155.69 9.15 57.00%

3 测试过程

  1. # http/1.1
  2. docker run -it http-client h2load -c200 -n100000 --h1 http://192.168.2.201:60001
  3. starting benchmark...
  4. spawning thread #0: 200 total client(s). 100000 total requests
  5. Application protocol: http/1.1
  6. progress: 10% done
  7. progress: 20% done
  8. progress: 30% done
  9. progress: 40% done
  10. progress: 50% done
  11. progress: 60% done
  12. progress: 70% done
  13. progress: 80% done
  14. progress: 90% done
  15. progress: 100% done
  16. finished in 6.47s, 15456.18 req/s, 12.42MB/s
  17. requests: 100000 total, 100000 started, 100000 done, 100000 succeeded, 0 failed, 0 errored, 0 timeout
  18. status codes: 100000 2xx, 0 3xx, 0 4xx, 0 5xx
  19. traffic: 80.35MB (84249000) total, 17.92MB (18795000) headers (space savings 0.00%), 58.36MB (61200000) data
  20. min max mean sd +/- sd
  21. time for request: 153us 73.38ms 12.78ms 4.51ms 72.82%
  22. time for connect: 29us 2.79ms 168us 477us 92.50%
  23. time to 1st byte: 8.65ms 30.75ms 19.81ms 4.82ms 67.00%
  24. req/s : 77.39 79.89 78.06 0.43 82.00%
  1. # http2-prior-knowledge m=1
  2. docker run -it http-client h2load -c200 -n100000 -m1 http://192.168.2.201:60002
  3. starting benchmark...
  4. spawning thread #0: 200 total client(s). 100000 total requests
  5. Application protocol: h2c
  6. progress: 10% done
  7. progress: 20% done
  8. progress: 30% done
  9. progress: 40% done
  10. progress: 50% done
  11. progress: 60% done
  12. progress: 70% done
  13. progress: 80% done
  14. progress: 90% done
  15. progress: 100% done
  16. finished in 9.51s, 10513.22 req/s, 7.41MB/s
  17. requests: 100000 total, 100000 started, 100000 done, 100000 succeeded, 0 failed, 0 errored, 0 timeout
  18. status codes: 100000 2xx, 0 3xx, 0 4xx, 0 5xx
  19. traffic: 70.49MB (73909800) total, 10.40MB (10900000) headers (space savings 38.76%), 58.36MB (61200000) data
  20. min max mean sd +/- sd
  21. time for request: 213us 1.79s 18.48ms 29.35ms 99.92%
  22. time for connect: 3.89ms 31.13ms 14.97ms 10.46ms 46.00%
  23. time to 1st byte: 16.89ms 1.80s 357.11ms 544.30ms 82.00%
  24. req/s : 52.73 55.08 54.02 0.63 67.50%
  1. # http2-prior-knowledge m=10
  2. docker run -it http-client h2load -c200 -n100000 -m10 http://192.168.2.201:60002
  3. starting benchmark...
  4. spawning thread #0: 200 total client(s). 100000 total requests
  5. Application protocol: h2c
  6. progress: 10% done
  7. progress: 20% done
  8. progress: 30% done
  9. progress: 40% done
  10. progress: 50% done
  11. progress: 60% done
  12. progress: 70% done
  13. progress: 80% done
  14. progress: 90% done
  15. progress: 100% done
  16. finished in 4.90s, 20428.10 req/s, 14.40MB/s
  17. requests: 100000 total, 100000 started, 100000 done, 100000 succeeded, 0 failed, 0 errored, 0 timeout
  18. status codes: 100000 2xx, 0 3xx, 0 4xx, 0 5xx
  19. traffic: 70.49MB (73909800) total, 10.40MB (10900000) headers (space savings 38.76%), 58.36MB (61200000) data
  20. min max mean sd +/- sd
  21. time for request: 257us 1.92s 92.82ms 83.03ms 98.00%
  22. time for connect: 1.50ms 32.88ms 16.34ms 11.61ms 35.00%
  23. time to 1st byte: 21.11ms 1.94s 335.67ms 516.76ms 82.00%
  24. req/s : 102.80 113.40 107.08 2.02 68.50%
  1. # http2-prior-knowledge m=100
  2. docker run -it http-client h2load -c200 -n100000 -m100 http://192.168.2.201:60002
  3. starting benchmark...
  4. spawning thread #0: 200 total client(s). 100000 total requests
  5. Application protocol: h2c
  6. progress: 10% done
  7. progress: 20% done
  8. progress: 30% done
  9. progress: 40% done
  10. progress: 50% done
  11. progress: 60% done
  12. progress: 70% done
  13. progress: 80% done
  14. progress: 90% done
  15. progress: 100% done
  16. finished in 3.55s, 28176.24 req/s, 19.86MB/s
  17. requests: 100000 total, 100000 started, 100000 done, 100000 succeeded, 0 failed, 0 errored, 0 timeout
  18. status codes: 100000 2xx, 0 3xx, 0 4xx, 0 5xx
  19. traffic: 70.49MB (73909800) total, 10.40MB (10900000) headers (space savings 38.76%), 58.36MB (61200000) data
  20. min max mean sd +/- sd
  21. time for request: 40.13ms 1.32s 632.70ms 161.49ms 77.65%
  22. time for connect: 6.27ms 61.61ms 27.21ms 10.12ms 78.00%
  23. time to 1st byte: 62.71ms 989.11ms 518.88ms 274.03ms 58.00%
  24. req/s : 140.88 172.80 155.69 9.15 57.00%

术语

  1. http/1.0 : http/1.0
  2. http/1.1 : 基于tcp,默认支持长连接
  3. h2 : 基于tls,支持多路复用.
  4. h2c : 基于tcp, 明文版的h2.
  5. http2-prior-knowledge : 基于tcp,客户端不经过http的协议升级协商,直接发起2的请求.

参考

h2load介绍: https://nghttp2.org/documentation/h2load-howto.html