原創2956317882018-01-24 21:45:28評論(0)623人閱讀java
Tomcat支持三種接收請求的處理方式:BIO、NIO、APR 。apache
1. BIO因爲每一個請求都要建立一個線程來處理,線程開銷比較大,不能再高併發的場景,性能也是最低的。 2. NIO是一個基於緩衝區、並能提供非阻塞I/O操做的Java API,比傳統的bio更好的併發性能。 3. APR(Apache Portable Run-time libraries)簡單理解,就是從操做系統級別解決異步IO問題,大幅度的提升服務器的處理和響應性能, 也是Tomcat運行高併發應用的首選模式。
所需軟件vim
* apr * apr-iconv * apr-util * tomcat-native
yum install -y apr-devel openssl-devel gcc make expat-devel libtool
tomcat
cd /usr/local/src wget https://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz tar xf apr-1.6.3.tar.gz cd apr-1.6.3/ ./configure --prefix=/usr/local/apr make && make install cd /usr/local/src wget https://mirrors.cnnic.cn/apache/apr/apr-iconv-1.2.2.tar.gz tar xf apr-iconv-1.2.2.tar.gz cd apr-iconv-1.2.2/ ./configure --with-apr=/usr/local/apr --prefix=/usr/local/apr-iconv make && make install cd /usr/local/src wget https://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz tar xf apr-util-1.6.1.tar.gz cd apr-util-1.6.1/ ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-apr-iconv=/usr/local/apr-iconv/bin/apriconv make && make install cd /usr/local/tomcat/bin/ tar xf tomcat-native.tar.gz cd /usr/local/tomcat/bin/tomcat-native-1.2.16-src/native ./configure --with-apr=/usr/local/apr --with-java-home=/usr/local/jdk8.0 make && make install echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib export LD_RUN_PATH=$LD_RUN_PATH:/usr/local/apr/lib' >> /etc/profile source /etc/profile
vim /usr/local/tomcat/conf/server.xml <Connector port="80" protocol="org.apache.coyote.http11.Http11AprProtocol" maxThreads="1000" minSpareThreads="100" acceptCount="900" disableUploadTimeout="true" connectionTimeout="20000" URIEncoding="UTF-8" enableLookups="false" redirectPort="8443" compression="on" compressionMinSize="1024" /> <!-- Define an AJP 1.3 Connector on port 8009 --> ##註釋掉下面那行,若是不用apache <!-- <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> -->
/usr/local/tomcat/bin/catalina.sh run 24-Jan-2018 21:39:17.695 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-80"]