Everyone has heard of the Java language features supported in Apache Tomcat6 NIO (New I/O), regardless of whether you are familiar with NIO technology, but you can certainly imagine that nio is a good thing. Indeed, the use of NiO on the server side will have better performance to enhance the server-side performance of concurrent processing. Please note: I am sorry that the NIO feature is not turned on in Tomcat6 in the default configuration options. So many of the friends who are using Tomcat6 thought they would be happy to use NIO. Cd/usr/local/tomcat1/confvi Server.xml One, set up the Tomcat connector pool.Yellow Sea in the configuration file, the following configuration is added: <executor name= "Tomcatthreadpool" nameprefix= "catalina-exec-" maxthreads= "$" minsparethreads= "/>" Ii. modifying JVM memory size under LinuxTo add the catalina.sh under Tomcat's bin, position cygwin=false before. Note the quotation marks to be taken, red for the newly added. # OS specific support. $var _must_ is set to either true or false. Java_opts= "-server-xms512m-xmx512m-xss256k-djava.awt.headless=true-dfile.encoding=utf-8-xx:permsize=64m-xx: maxpermsize=128m "Cygwin=false Third, view the default values for the current system open files:Ulimit-a No, it's 1024. File system maximum number of open files: Cat/proc/sys/fs/file-max My machine is 396399. Modify file system maximum open files: Echo 396399 >/proc/sys/fs/file-max This value can only be set to a small setting that cannot exceed the limit value. 1. Set the maximum number of open files in the vi/etc/security/limits.conf file add: * Soft Nofile 65535 * Hard Nofile 65535 Finally with restart Ulimit-a again, open files value, if changed, then take effect. Iv. installing Tomcat's APR for improved performanceDiscover that Tomcat can use Apache portable Runtime to provide stronger performance, improve the processing power of Web static pages, and no longer require dedicated Web server to handle static pages. Apr and tomcat-native provide better scalability, performance, and integration into local server technology. If you do not have APR technology, the following prompt appears when you start Tomcat: Info: The APR based Apache Tomcat Native Library which allows optimal performance in production environments is not found O n the Java.library.path:/usr/java/jdk1.6.0_06/jre/lib/i386/client:/usr/java/jdk1.6.0_06/jre/lib/i386:/usr/java/ jdk1.6.0_06/ Jre/. /lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib As required by official instructions: APR Library OpenSSL Libraries OpenSSL can be used Yum Install-y openssl-devel
Apr or download *.gz to install. (1) Install Apr mkdir /root/softwarecd/root/softwarewget Http://mirror.bit.edu.cn/apache/apr/apr-1.4.6.tar.gztar zxvf apr-1.4.6.tar.gz cd apr-1.4.6./configure--prefix=/usr/local/apr make do install
appears when installing APR ./configure--PREFIX=/USR/LOCAL/APR Rm:cannot remove ' Libtoolt ': No such file or directory Workaround: Vim Configure In line 30048 # $RM "$cfgfile" preceded by # comment out In the RE./configure (2) Installation Apr-iconv Cd/root/softwarewget HTTP://MIRROR.BIT.EDU.CN/APACHE/APR/APR-ICONV-1.2.1.TAR.GZTAR-ZXVF apr-iconv-1.2.1.tar.gz CD apr-iconv-1.2.1./configure--prefix=/usr/local/apr-iconv--with-apr=/usr/local/apr make do install
(3) Installation Apr-util Cd/root/softwarewget Http://mirror.bit.edu.cn/apache/apr/apr-util-1.4.1.tar.gztar ZXVF APR-UTIL-1.4.1.TAR.GZCD apr-util-1.4.1./configure--prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-apr-iconv=/usr/ Local/apr-iconv/bin/apriconv make make install
PS: I have experienced two different installed APR, the first time is my CentOS did not upgrade, an upgrade, before the upgrade will have some assorted error said no, generally are less package what, you give it yum update on the line, recommended upgrade after reloading, will be more normal a little ~ ~ (4) Installation tomcat-native Tomcat-native-1.1.27-src.tar.gz This I installed Tomcat inside himself, in the bin directory, if you do not find, go online next on the line. Specifically, I don't know. ⊙﹏⊙ b Khan, find Apache's official Internet café Cd/usr/local/tomcat1/bin tar zxvf tomcat-native.tar.gz cd tomcat-native-1.1.27-src/jni/native . Configure--with-apr=/usr/local/aprmake make install
(5) Setting environment variables for APR Cd/usr/local/tomcat1/binvi catalina.sh
Under #!/bin/sh of the file, add the following: #!/bin/shld_library_path= $LD _library_path:/usr/local/apr/libexport Ld_library_path
In this case, we just added the Tomcat APR, without destroying other Tomcat configuration information. After starting Tomcat, look at the log: Bin/startup.shhead Logs/catalina.out
You can see the following results: Well, you can run it, but not test how much its performance has improved. Performance can be significantly improved with high concurrency. Reboot will take effect when the installation is complete. If you use the default protocal is APR, but it is better to change the protocol to Org.apache.coyote.http11.Http11AprProtocol, will be more explicit. Cd/usr/local/tomcat1/confvi Server.xml
Replace the connector content as follows: <connector port= "8080" protocol= "org.apache.coyote.http11.Http11AprProtocol" executor= " Tomcatthreadpool " compression=" on " compressionminsize=" 2048 " maxthreads=" 30000 " minsparethreads= "maxsparethreads=" " 2048" enablelookups= "false" redirectport= "8443 " Acceptcount= "35000" debug= "0" connectiontimeout= "40000" disableuploadtimeout= "true" uriencoding= "UTF-8" usebodyencodingforuri= "true"/>
Here we begin to test the pressure of the two protocols: CentOS Installation AB Yum Install Httpd-tools
When we're ready, we can test it. AB-KC 1000-n 10000 http://localhost:8080/
This command will be connected 10,000 times using 1000 concurrent. The results are as follows: The quickest time for NIO: The fastest time of Apr: The gap is around 50%, it is highly recommended to use APR protocol!!! Do not use the NIO protocol +APR Library supported behavior!!!!!!!! If you do not install APR or if you do not have the option to enable APR, use the following alternatives:<connector port= "8080" protocol= "Org.apache.coyote.http11.Http11NioProtocol" executor= " Tomcatthreadpool " compression=" on " compressionminsize=" 2048 " maxthreads=" 30000 " minsparethreads= "maxsparethreads=" " 2048" enablelookups= "false" redirectport= "8443 " Acceptcount= "35000" debug= "0" connectiontimeout= "40000" disableuploadtimeout= "true" uriencoding= "UTF-8" usebodyencodingforuri= "true"/>
(Editor: IT) |