码迷,mamicode.com
首页 > 其他好文 > 详细

tomcat运行模式(bio,aio,apr)

时间:2016-05-13 17:26:58      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:tomcat运行模式(bio   aio   apr)   

   tomcat中间件的启动运行模式有分为3种,可以在启动运行控制台和启动日志中看出.默认模式bio(阻塞IO)  缺点:能非常低下,没有经过任何优化处理和支持,并发量高时,线程数较多,浪费资源.nio(异步IO)利用Java的异步IO处理,可以通过少量的线程处理大量的请求.apr(系统解决IO阻塞)从操作系统层面解决io阻塞问题,必须手动安装apr和native包.


1.bio模式(默认)

[root@node3 conf]# tailf  ../logs/catalina.out

May 13, 2016 3:23:17 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-82"]
May 13, 2016 3:23:17 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8010"]
May 13, 2016 3:23:17 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4365 ms


2.nio模式

[root@node3 conf]# vim server.xml

<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol

         connectionTimeout="20000" redirectPort="8443"/>

[root@node3 conf]# tailf  ../logs/catalina.out

May 13, 2016 3:23:17 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-82"]
May 13, 2016 3:23:17 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8010"]
May 13, 2016 3:23:17 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4365 ms


3.apr模式

下载apr:http://mirrors.cnnic.cn/apache//apr/apr-1.5.2.tar.gz

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

下载apr-iconv:http://mirrors.cnnic.cn/apache//apr/apr-iconv-1.2.1.tar.gz

[root@db01 ~]# tar xvf apr-1.5.2.tar.gz
[root@db01 ~]# tar xvf apr-util-1.5.4.tar.gz

[root@db01 ~]# tar xvf apr-iconv-1.2.1.tar.gz

[root@db01 ~]# cd apr-1.5.2

[root@db01 ~]# ./configure --prefix=/usr/local/apr-1.5.2  && make && make install

[root@db01 ~]# cd apr-iconv-1.2.1

[root@db01 ~]# ./configure --prefix=/usr/local/apr-iconv-1.2.1 --with-apr=/usr/local/apr-1.5.2   && make && make install

[root@db01 ~]# cd apr-util-1.5.4

[root@db01 ~]# ./configure --prefix=/usr/local/apr-util-1.5.4  --with-apr=/usr/local/apr-1.5.2  --with-iconv=/usr/local/apr-iconv-1.2.1  && make && make install

[root@db01 ~]# cd /usr/local/tomcat-7.0.67/bin/

[root@db01 bin]# tar xvf tomcat-native.tar.gz
[root@db01 bin]# cd tomcat-native-1.1.33-src/jni/native/
[root@db01 native]# ./configure --with-apr=/usr/local/apr-1.5.2 --with-java=/usr/local/jdk1.7.0_80
[root@db01 native]# make && make install

[root@db01 native]# vim /etc/profile
     export LD_LIBRARY_PATH=/usr/local/apr-1.5.2/lib
[root@db01 native]# source /etc/profile

[root@node3 conf]# tailf  ../logs/catalina.out

May 13, 2016 3:23:17 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-82"]
May 13, 2016 3:23:17 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8010"]
May 13, 2016 3:23:17 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4365 ms

本文出自 “一起走过的日子” 博客,请务必保留此出处http://tongcheng.blog.51cto.com/6214144/1773065

tomcat运行模式(bio,aio,apr)

标签:tomcat运行模式(bio   aio   apr)   

原文地址:http://tongcheng.blog.51cto.com/6214144/1773065

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!