Tomcat response time is increasing as concurrency

2019-09-18 06:35发布

When I am increasing concurrency -c in ab (apache bench) then I am getting different response time.

-c      99%
3       2ms
5       4ms
8       6ms

If I increase -c further then response time will increase as well.My code is extremely simple, No thread starvation, no blocking, etc. Then why the response time is getting increased?

I think that ab -c 8 means 8 simultaneous request would be made to http://localhost:8070/benchmark. So is it possible that requests are getting pooled at tomcat? If it is so then how can I make tomcat handle more concurrent users with less response time (4ms at 99%)?

@RestController
public class PerformanceController {

    @RequestMapping(value="/benchmark",method=RequestMethod.GET)
    public String getRetargetingData(){
        return "Just plain call";
    }

}

ritesh@ritesh:~$ ab -n 10000 -c 3 'http://localhost:8070/benchmark'
Server Software:        Apache-Coyote/1.1
Server Hostname:        localhost
Server Port:            8070

Document Path:          /benchmark
Document Length:        15 bytes

Concurrency Level:      3
Time taken for tests:   2.602 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      4050000 bytes
HTML transferred:       150000 bytes
Requests per second:    3843.57 [#/sec] (mean)
Time per request:       0.781 [ms] (mean)
Time per request:       0.260 [ms] (mean, across all concurrent requests)
Transfer rate:          1520.16 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:     0    1   0.5      1      23
Waiting:        0    1   0.4      1      23
Total:          0    1   0.5      1      24

Percentage of the requests served within a certain time (ms)
  50%      1
  66%      1
  75%      1
  80%      1
  90%      1
  95%      1
  98%      2
  99%      2
 100%     24 (longest request)


ritesh@ritesh:~$ ab -n 10000 -c 6 'http://localhost:8070/benchmark'
Server Software:        Apache-Coyote/1.1
Server Hostname:        localhost
Server Port:            8070

Document Path:          /benchmark
Document Length:        15 bytes

Concurrency Level:      6
Time taken for tests:   1.814 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      4050000 bytes
HTML transferred:       150000 bytes
Requests per second:    5514.16 [#/sec] (mean)
Time per request:       1.088 [ms] (mean)
Time per request:       0.181 [ms] (mean, across all concurrent requests)
Transfer rate:          2180.89 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       1
Processing:     0    1   0.9      1      22
Waiting:        0    1   0.8      1      22
Total:          0    1   0.9      1      22

Percentage of the requests served within a certain time (ms)
  50%      1
  66%      1
  75%      1
  80%      1
  90%      2
  95%      2
  98%      3
  99%      4
 100%     22 (longest request)


ritesh@ritesh:~$ ab -n 10000 -c 8 'http://localhost:8070/benchmark'

Server Software:        Apache-Coyote/1.1
Server Hostname:        localhost
Server Port:            8070

Document Path:          /benchmark
Document Length:        15 bytes

Concurrency Level:      8
Time taken for tests:   1.889 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      4050000 bytes
HTML transferred:       150000 bytes
Requests per second:    5293.55 [#/sec] (mean)
Time per request:       1.511 [ms] (mean)
Time per request:       0.189 [ms] (mean, across all concurrent requests)
Transfer rate:          2093.64 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       2
Processing:     0    1   1.8      1      50
Waiting:        0    1   1.8      1      50
Total:          0    1   1.8      1      50

Percentage of the requests served within a certain time (ms)
  50%      1
  66%      1
  75%      2
  80%      2
  90%      2
  95%      3
  98%      5
  99%      6
 100%     50 (longest request)
ritesh@ritesh:~$ ab -n 10000 -c 500 'http://localhost:8070/benchmark'
Server Software:        Apache-Coyote/1.1
Server Hostname:        localhost
Server Port:            8070

Document Path:          /benchmark
Document Length:        15 bytes

Concurrency Level:      500
Time taken for tests:   1.830 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      4050000 bytes
HTML transferred:       150000 bytes
Requests per second:    5464.11 [#/sec] (mean)
Time per request:       91.506 [ms] (mean)
Time per request:       0.183 [ms] (mean, across all concurrent requests)
Transfer rate:          2161.10 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   25 154.8      0    1001
Processing:     1   23  45.7     12     818
Waiting:        1   23  45.6     12     818
Total:          2   48 188.5     12    1818

Percentage of the requests served within a certain time (ms)
  50%     12
  66%     17
  75%     22
  80%     26
  90%     45
  95%     66
  98%   1021
  99%   1220
 100%   1818 (longest request)

0条回答
登录 后发表回答