AJP与HTTP比较和分析
系统环境:
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与HTTP比较和分析的更多相关文章
- Tomcat AJP 文件包含漏洞复现(CVE-2020-1938)
漏洞原理 Tomcat配置了两个Connecto,它们分别是HTTP和AJP. HTTP默认端口为8080,处理http请求:AJP默认端口8009,用于处理 AJP 协议的请求. AJP比http更 ...
- Tomcat配置(三):tomcat处理连接的详细过程
*/ .hljs { display: block; overflow-x: auto; padding: 0.5em; color: #333; background: #f8f8f8; } .hl ...
- Tomcat(三):tomcat处理连接的详细过程
Tomcat系列文章:http://www.cnblogs.com/f-ck-need-u/p/7576137.html tomcat可以处理静态资源的请求,也可以通过servlet处理动态资源的请求 ...
- AJP协议总结与分析
Tomcat服务器通过Connector连接器组件与客户程序建立连接,Connector组件负责接收客户的请求,以及把Tomcat服务器的响应结果发送给客户.默认情况下,Tomcat在server.x ...
- tomcat源码分析(三)一次http请求的旅行-从Socket说起
p { margin-bottom: 0.25cm; line-height: 120% } tomcat源码分析(三)一次http请求的旅行 在http请求旅行之前,我们先来准备下我们所需要的工具. ...
- tomcat源码分析(一)从tomcat架构说起
p { margin-bottom: 0.25cm; line-height: 120% }
- Tomcat源码分析
前言: 本文是我阅读了TOMCAT源码后的一些心得. 主要是讲解TOMCAT的系统框架, 以及启动流程.若有错漏之处,敬请批评指教! 建议: 毕竟TOMCAT的框架还是比较复杂的, 单是从文字上理解, ...
- Tomcat处理HTTP请求源码分析(上)(转)
转载自:http://www.infoq.com/cn/articles/zh-tomcat-http-request-1 很多开源应用服务器都是集成tomcat作为web container的,而且 ...
- 服务器程序源代码分析之三:gunicorn
服务器程序源代码分析之三:gunicorn 时间:2014-05-09 11:33:54 类别:网站架构 访问: 641 次 gunicorn是一个python web 服务部署工具,类似flup,完 ...
随机推荐
- TCP/IP四层协议模型与ISO七层模型
TCP/IP四层协议模型与ISO七层模型 在世界上各地,各种各样的电脑运行着各自不同的操作系统为大家服务,这些电脑在表达同一种信息的时候所使用的方法是千差万别.就好像圣经中上帝打乱了各地人的口音,让他 ...
- 【MediaElement】WPF视频播放器【3】
一.前言 对于<MediaElement>前两章介绍了差不多了,其实好的界面还需要UI工程师的配合,比如帮忙设计下按钮的样式等等.同样视频本身也需要吸引人,不然做的再好的播放器也没用.之后 ...
- 【BZOJ4011】【HNOI2015】落忆枫音(动态规划)
[BZOJ4011][HNOI2015]落忆枫音(动态规划) 题面 BZOJ 洛谷 Description 「恒逸,你相信灵魂的存在吗?」 郭恒逸和姚枫茜漫步在枫音乡的街道上.望着漫天飞舞的红枫,枫茜 ...
- 洛谷 P3345 [ZJOI2015]幻想乡战略游戏 解题报告
P3345 [ZJOI2015]幻想乡战略游戏 题目描述 傲娇少女幽香正在玩一个非常有趣的战略类游戏,本来这个游戏的地图其实还不算太大,幽香还能管得过来,但是不知道为什么现在的网游厂商把游戏的地图越做 ...
- poj 1945 Power Hungry Cows A*
Description: 就是给你一个数,你可以把它自乘,也可以把他乘或除以任意一个造出过的数,问你最多经过多少次操作能变换成目标数 思路:这题真的不怎么会啊.n = 20000,每一层都有很 ...
- ASCLL表
ASCII码表完整版 ASCII值 控制字符 ASCII值 控制字符 ASCII值 控制字符 ASCII值 控制字符 0 NUT 32 (space) 64 @ 96 . 1 SOH 33 ! 65 ...
- SpringMVC 重定向
在返回视图名字的字符串前面加forword:或redirect:前缀是就会对他们做特殊处理,它们分别是转发和重定向 我们测试一个重定向操作把 Java代码 @RequestMapping(" ...
- Codeforces Round #207 (Div. 2)A B C E 水 思路 set 恶心分类
A. Group of Students time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Swagger2 添加HTTP head参数,解决用户是token信息保留
转:http://blog.csdn.net/u014044812/article/details/71473226 大家使用swagger往往会和JWT一起使用,而一般使用jwt会将token放在h ...
- zabbix添加cpu使用率图形监控
zabbix版本: 3.2.5 zabbix 自带的windows模板中没有监控cpu使用率的,可以在模板里自己添加 1. 配置 ---> 模板---> Template OS Windo ...