Java 随着apache bench中并发性的增加,Tomcat响应时间也在增加
当我在ab apache bench中增加并发性-c时,我会得到不同的响应时间Java 随着apache bench中并发性的增加,Tomcat响应时间也在增加,java,rest,tomcat,apachebench,Java,Rest,Tomcat,Apachebench,当我在ab apache bench中增加并发性-c时,我会得到不同的响应时间 -c 99% 3 2ms 5 4ms 8 6ms 如果我进一步增加-c,那么响应时间也会增加。我的代码非常简单,没有线程饥饿,没有阻塞,等等。那么为什么响应时间会增加呢 我认为ab-C8意味着会同时向http://localhost:8070/benchmark. 那么,请求是否有可能在tomcat上汇集?如果是这样的话,我怎样才能让tomcat以更少的响应时间4ms(
-c 99%
3 2ms
5 4ms
8 6ms
如果我进一步增加-c,那么响应时间也会增加。我的代码非常简单,没有线程饥饿,没有阻塞,等等。那么为什么响应时间会增加呢
我认为ab-C8意味着会同时向http://localhost:8070/benchmark. 那么,请求是否有可能在tomcat上汇集?如果是这样的话,我怎样才能让tomcat以更少的响应时间4ms(99%)处理更多并发用户呢
我不确定此测试是否告诉您任何有用的信息,因为您没有使用实际的网络连接。如果你在两台不同的机器之间进行测试,你的响应时间会大大增加,以至于2ms和6ms之间的差异只是噪音。@SteveC:谢谢你指出这一点。但我更好奇的是,为什么即使在同一台机器上,响应时间也在增加?嗯,你激起了我的好奇心。所以我自己也尝试了类似的测试,尽管在WildFly 8.1.0.Final中使用了标准JAX-RS。然后,我可以使用2kB WAR文件进行测试。在我的MacBook Pro上运行时,99%和低于99%的响应时间为1ms或更少,即使在-C16。我必须让操作系统在两次测试之间休息,否则它将开始节流。因此,我发现的任何变化都可能是操作系统级别的事情的结果。@SteveC:我的硬件与你的相比并不好。所以我的-c数更少。但即使您在您的机器上进行了测试,我希望您会发现与非常简单的普通代码相比,数字少得可笑。试着运行-C100。如果我没记错的话,tomcat可以管理200个并发用户。
@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)