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

餘二五發表於2017-11-16

   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

本文轉自 z597011036 51CTO部落格,原文連結:http://blog.51cto.com/tongcheng/1773065,如需轉載請自行聯絡原作者


相關文章