APR模式下,性能有了明显的提高:
APR模式需要安装才能生效,我是在windows模式下安装APR。一般在Windows下,可以直接下载编译好的二进制版本的dll库文件来使Tomcat启用 APR,下载地址是:http://tomcat.heanet.ie/native/1.1.19/binaries/win32/
我使用tomcat6.0.23 最低版本装1.1.18,下载 tcnative-1.dll之后,拷贝到bin下覆盖原 tcnative-1.dll,安装完成。
启动tomcat,可以看到如下的字样,表示安装成功:
大
测试arp下的并发情况:
第一次测试:
100% 680 (longest request)
第二次测试:
C:\Users\kxm>ab -k -n 5000 -c 500 http://localhost:8080/SMS
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
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 500 requests
..........................
Concurrency Level: 500
Time taken for tests: 3.923 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Non-2xx responses: 5000
Keep-Alive requests: 0
Total transferred: 715000 bytes
HTML transferred: 0 bytes
Requests per second: 1274.46 [#/sec] (mean)
Time per request: 392.322 [ms] (mean)
Time per request: 0.785 [ms] (mean, across all concurrent requests)
Transfer rate: 177.98 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.5 0 13
Processing: 37 374 62.4 390 417
Waiting: 3 196 111.6 196 411
Total: 38 375 62.4 390 417
Percentage of the requests served within a certain time (ms)
50% 390
66% 395
75% 399
80% 403
90% 408
95% 414
98% 415
99% 416
100% 417 (longest request)
相对BIO和NIO有了大幅提升。
暂时的结论是APR>BIO≌NIO。ARP优于BIO,BIO略优于NIO。