基准测试(三)

结合应用。

业务逻辑很简单:只是简单的查询。

public Sbtest1 list(){
        EntityWrapper wrapper = new EntityWrapper<>();
        Sbtest1 sbtest1 = sbtest1Mapper.selectById(4);
        System.out.println(sbtest1);
        return  sbtest1;
    }

使用的最大连接数数是20。

spring:
  datasource:
      maxActive: 20

使用ab进行压测。
测试结果:并发数1000
qps:2290千。
平均每个请求延迟436ms。

ab -n100000 -c1000 http://localhost:8080/test/test2
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:
Server Hostname:        localhost
Server Port:            8080

Document Path:          /test/test2
Document Length:        208 bytes

Concurrency Level:      1000
Time taken for tests:   43.658 seconds
Complete requests:      100000
Failed requests:        0
Total transferred:      33400000 bytes
HTML transferred:       20800000 bytes
Requests per second:    2290.55 [#/sec] (mean)
Time per request:       436.577 [ms] (mean)
Time per request:       0.437 [ms] (mean, across all concurrent requests)
Transfer rate:          747.11 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.5      0      10
Processing:    57  434  56.8    420    1030
Waiting:        3  318  88.0    320     982
Total:         58  435  56.8    420    1031

Percentage of the requests served within a certain time (ms)
  50%    420
  66%    433
  75%    454
  80%    474
  90%    504
  95%    521
  98%    559
  99%    599
 100%   1031 (longest request)

直接测试tomcat的qps。

@GetMapping("test")
    public Object listProvinceCompany() {
        System.out.println("hello");
        return "ok";
    }

测试结果:并发数1000
qps:3000千。
平均每个请求延迟327ms。

D:\develop_tools\develop_tools_decompress\Apache24\bin>ab -n100000 -c1000 http://localhost:8080/test/test
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:
Server Hostname:        localhost
Server Port:            8080

Document Path:          /test/test
Document Length:        4 bytes

Concurrency Level:      1000
Time taken for tests:   32.704 seconds
Complete requests:      100000
Failed requests:        0
Total transferred:      12200000 bytes
HTML transferred:       400000 bytes
Requests per second:    3057.71 [#/sec] (mean)
Time per request:       327.042 [ms] (mean)
Time per request:       0.327 [ms] (mean, across all concurrent requests)
Transfer rate:          364.30 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.6      0     502
Processing:    64  320  46.3    305     920
Waiting:       10  163  94.4    159     856
Total:         65  321  46.4    305     921

Percentage of the requests served within a certain time (ms)
  50%    305
  66%    316
  75%    329
  80%    344
  90%    379
  95%    402
  98%    425
  99%    445
 100%    921 (longest request)

再测数据库查询。
增大连接数到800。

      maxActive: 800

测试结果:并发数1000
qps:2318千。
平均每个请求延迟431。

可见:增大连接数,对性能没有什么提高。

D:\develop_tools\develop_tools_decompress\Apache24\bin>ab -n100000 -c1000 http://localhost:8080/test/test2
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:
Server Hostname:        localhost
Server Port:            8080

Document Path:          /test/test2
Document Length:        208 bytes

Concurrency Level:      1000
Time taken for tests:   43.135 seconds
Complete requests:      100000
Failed requests:        0
Total transferred:      33400000 bytes
HTML transferred:       20800000 bytes
Requests per second:    2318.32 [#/sec] (mean)
Time per request:       431.346 [ms] (mean)
Time per request:       0.431 [ms] (mean, across all concurrent requests)
Transfer rate:          756.17 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   2.8      0     503
Processing:    41  419  88.1    403    1773
Waiting:       33  315 106.1    305    1466
Total:         42  419  88.2    404    1773

Percentage of the requests served within a certain time (ms)
  50%    404
  66%    408
  75%    411
  80%    414
  90%    422
  95%    464
  98%    682
  99%    927
 100%   1773 (longest request)

说明:
1、以上测试数据,并不能表名,tomcat的极限qps就是3000,而是,ab并没有把tomcat的极限性能测出来。
2、但是有一点是正确的,就是增大连接数,对性能没有影响,因为,应用服务器本身的qps的限制,使用不了那么多连接数。

你可能感兴趣的:(基准测试(三))