系统环境:
OS:Ubuntu 10.10 (2G)
Servlet Container:tomcat-tomcat-7.0.23 (最大内存:default 256M maxThreads:500)
Web server: apache2.2 (maxClient:250)
设置apache最大连接数
在/usr/local/etc/apache22/httpd.conf中加载MPM配置(去掉前面的注释):
# Server-pool management (MPM specific)
Include etc/apache22/extra/httpd-mpm.conf
修改d-mpm.conf中对应module如下
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
ServerLimit 3000
MaxClients 2000
MaxRequestsPerChild 0
</IfModule>]
一、benchmark测试方法
./ab -n 100000 -c 100 http://localhost/test
使用ab进行测试,当并发较高时,会出现以下错误
错误1:apr_socket_recv: Connection reset by peer (104)
apache2.2及以下版本
修改support下面的ab.c源代码, 大概在
line 1369, 修改成
1368 return;
1369 } else {
1370 //apr_err("apr_socket_recv", status);
1371 bad++;
1372 close_connection(c);
1373 return;
1374 }
然后编译安装
错误2:Too many open files (24)
(PS;使用AJP协议和HTTP协议,多次进行测试,取测试结果较好的一次进行比较)
二、使用AJP后的benchmark
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: 80
Document Path: /test
Document Length: 347 bytes
Concurrency Level: 100
Time taken for tests: 50.270 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 48712175 bytes
HTML transferred: 34708675 bytes
Requests per second: 1989.24 [#/sec] (mean)
Time per request: 50.270 [ms] (mean)
Time per request: 0.503 [ms] (mean, across all concurrent requests)
Transfer rate: 946.29 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 23 15.3 21 714
Processing: 2 27 19.8 24 724
Waiting: 1 22 15.4 20 714
Total: 9 50 25.3 44 747
Percentage of the requests served within a certain time (ms)
50% 44
66% 49
75% 53
80% 55
90% 64
95% 73
98% 87
99% 101
100% 747 (longest request)
三、使用HTTP 后的benchmark
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: Apache-Coyote/1.1
Server Hostname: localhost
Server Port: 80
Document Path: /test
Document Length: 347 bytes
Concurrency Level: 100
Time taken for tests: 55.392 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 51415934 bytes
HTML transferred: 34710757 bytes
Requests per second: 1805.32 [#/sec] (mean)
Time per request: 55.392 [ms] (mean)
Time per request: 0.554 [ms] (mean, across all concurrent requests)
Transfer rate: 906.47 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 24 10.1 24 185
Processing: 8 31 10.7 28 215
Waiting: 1 26 10.0 24 198
Total: 13 55 12.3 51 247
Percentage of the requests served within a certain time (ms)
50% 51
66% 54
75% 58
80% 60
90% 66
95% 74
98% 86
99% 99
100% 247 (longest request)
四、结论
If integration with the native webserver is needed for any reason, an AJP connector will provide faster performance than proxied HTTP.
前端apache,后端tomcat,通过ajp协议访问性能优于http协议,随着并发量的提升,效果会更加趋于明显。可以从吞吐率和总时间开销上观察。
(吞吐率:单位时间内计算机的处理请求来描述其并发处理能力)
可以参考下ajp协议的设计
http://httpd.apache.org/docs/2.2/mod/mod_proxy_ajp.html
原因总结如下:
1、ajp使用长连接保持webServer和servlet Container的通信,减少了建立tcp连接的开销。可以通过观察tomcat/manager 下serverStatus,ajp建立的连接都处于keepalive的状态。
2、ajp使用一定的协议格式,减少了传递的报文数据大小,节省了带宽。可以通过观察ajp和http 的benchmark报告重看到,Total transferred 一项有明显的区别。
分享到:
相关推荐
ajp各参数含义,不晓得对与错,希望对大家有帮助啦
安全加固Tomca漏洞,禁用AJP接口。
Apache JServ协议(AJP)是一种二进制协议,可以将来自Web服务器的入站请求代理到 位于Web服务器后面的应用程序服务器。不建议在互联网上公开使用AJP服务。 如果AJP配置错误,可能会允许攻击者访问内部资源。
jetty-ajp-6.1.6rc0.jar
主要讲解WIN7中IIS7 如何使用AJP连接tomcat.
Nginx插件,增加对ajp协议的支持,提高效率,已经使用Tomcat 6通过测试。
超智能的tomcat和iis整合工具
可以用来验证tomcat-ajp-lfi的漏洞
White bells with pendulums of aniseHarmonies of glass where my lips become puppetsAnd take me to a gentle river of warm currentWhere I dream with seeing your gaze.But I refuse to open my eyes ...
apache-tomcat-9.0.12.tar.gz 下载,jdk-8u221-linux-x64.tar.gz 下载,Python-3.7.3.tgz 下载!
nginx_ajp_module-通过Nginx支持AJP协议代理 概要 http { upstream tomcats { server 127.0.0.1:8009; keepalive 10; } server { listen 80; location / { ajp_keep_conn on; ajp_pass tomcats; } } } ...
CNVD-2020-10487-Tomcat-Ajp-lfi
apache安装,配置;tomcat下载,配置,设置为服务,有详解
apache服务器和tomcat服务器之间实现URL代理的module.so工具类文件
NULL 博文链接:https://xiaowei-qi-epro-com-cn.iteye.com/blog/2175105
nginx_ajp_module-0.3.0.zip 通过这个模块,Nginx可以直接连接AJP端口。 安装示例: $ wget 'http://nginx.org/download/nginx-1.4.4.tar.gz' $ tar -xzvf nginx-1.4.4.tar.gz $ cd nginx-1.4.4/ $ ./configure --...
nginx_ajp_module-0.3.0.tar.gz 通过这个模块,Nginx可以直接连接AJP端口。 安装示例: $ wget 'http://nginx.org/download/nginx-1.4.4.tar.gz' $ tar -xzvf nginx-1.4.4.tar.gz $ cd nginx-1.4.4/ $ ./configure -...
nginx配置ajp-附件资源
2.默认http与ajp请求实现non-blocking技术,即NIO技术。 3.多个应用发布的时候可以先打成jar包,然后打成一个总的war发布。(这句翻译不太准,意思大概是这样子的) 4.默认支持应用工程字符集为UFT-8 5.提升了日志...