tomcat 采用 APR apache poartable runtime

来源:互联网 发布:交大医学院网络挂号 编辑:程序博客网 时间:2024/06/13 18:15

http://love-love-l.blog.163.com/blog/static/21078304201311564236996/


有时间学习一下


需要的文件下载:

下载 http://apache.fayea.com//apr/apr-1.5.2.tar.gz

下载 http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.4.tar.gz

wget https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz


注意在安装apr时候:

直接打开/usr/local/src/apr-1.4.6/configure  把 $RM “$cfgfile” 那行删除掉 

$RM “$cfgfile”  大约在 42302 行



1 ./configure --prefix=/usr/local/apr

2. ./configure --with-apr=/usr/local/apr

3./configure --with-apr=/usr/local/apr --with-ssl=/usr/local/openssl


make && make install 都需要

运行tomcat

最后观察tomcat 日志:

08-Jun-2017 06:19:29.336 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/opt/soft/tomcat/temp
08-Jun-2017 06:19:29.340 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat
Native library 1.2.12 using APR version 1.5.2.
08-Jun-2017 06:19:29.340 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
08-Jun-2017 06:19:29.340 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
08-Jun-2017 06:19:29.355 信息 [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.2l  25 May 2017)



 Java Code 
1
2
3
4
5
6
要测APR给tomcat带来的好处最好的方法是在慢速网络上(模 拟Internet),将Tomcat线程数开到300以上的水平,然后模 拟一大堆并发请求。
如果不配APR,基本上300个线程狠快就会 用满,以后的请求就只好等待。但是配上APR之后,并发的线 程数量明显下降,
从原来的300可能会马上下降到只有几十, 新的请求会毫无阻塞的进来。 APR对于Tomcat最大的作用就是socket调度。 
你在局域网环境测,就算是400个并发,也是一瞬间就处理 / 传 输完毕,但是在真实的Internet环境下,页面处理时间只占 0.1 % 都不到,
绝大部分时间都用来页面传输。如果不用APR, 一个线程同一时间只能处理一个用户,势必会造成阻塞。所以 生产环境下用apr是非常必要的。


原创粉丝点击