标签:循环 name ssi form make 复用器 png gre cti
1、同步概念:
2、Java对BIO、NIO、AIO的支持:
3、BIO、NIO、AIO适用场景分析:
BIO方式适用于连接数目比较小且固定的架构,这种方式对服务器资源要求比较高,并发局限于应用中,JDK1.4以前的唯一选择,但程序直观简单易理解,性能非常低下,没有经过任何优化处理和支持。
Nio(new I/O),是java SE1.4及后续版本提供的一种新的I/O操作方式(即java.nio包及其子包)。Java nio 是一个基于缓冲区,并能提供非阻塞I/O操作的java API,因此nio也被看成是non-blocking I/O的缩写。它拥有比传统I/O操作(bio)更好的并发运行性能。适用于连接数目多且连接比较短(轻操作)的架构,比如聊天服务器,并发局限于应用中。
安装起来最困难,但是从操作系统级别来解决异步的IO问题,大幅度的提高了性能
Tomcat8默认运行模式为NIO
[root@localhost ~]# tail -1 /usr/local/tomcat8/logs/catalina.out
08-Apr-2019 11:45:01.589 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
[root@localhost ~]# vim /usr/local/tomcat8/conf/server.xml
<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000"
redirectPort="8443"
compression="on"
compressionMinSize="50"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" />
[root@localhost ~]# /usr/local/tomcat8/bin/shutdown.sh
[root@localhost ~]# /usr/local/tomcat8/bin/startup.sh
[root@localhost ~]# tail -f /usr/local/tomcat8/logs/catalina.out
08-Apr-2019 11:56:02.441 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
模式三Apr:
[root@localhost ~]# rpm -e apr --nodeps
[root@localhost ~]# yum -y install apr apr-devel
[root@localhost ~]# cp /usr/local/tomcat8/bin/tomcat-native.tar.gz /root/
[root@localhost ~]# tar xf tomcat-native.tar.gz
[root@localhost ~]# cd tomcat-native-1.2.12-src/native/
[root@localhost native]# ./configure --with-apr=/usr/bin/apr-1-config --with-java-home=/usr/local/java && make && make install
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/apr/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR‘
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH‘ environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH‘ environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR‘ linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf‘
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
[root@localhost tomcat-native-1.2.17-src]# cd
[root@localhost native]# vim /usr/local/tomcat8/bin/catalina.sh##末尾添加,设置环境变量
CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
[root@localhost native]# vim /usr/local/tomcat8/conf/server.xml
69 <Connector port="8080" protocol="org.apache.coyote.http11.Http11AprProtocol" [root@localhost ~]# vim /etc/profile##在最后一行添加
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib
[root@localhost native]# source /etc/profile //加载进程文件profile
[root@localhost native]# /usr/local/tomcat8/bin/shutdown.sh
[root@localhost native]# /usr/local/tomcat8/bin/startup.sh
[root@localhost ~]# netstat -utpln |grep java
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 2748/java
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 2748/java
[root@localhost native]# tail -3 /usr/local/tomcat8/logs/catalina.out
08-Apr-2019 12:20:20.455 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
解决重启tomcat服务后,8005端口延迟启动的问题;
[root@localhost ~]# vi /usr/local/java/jre/lib/security/java.security
117 securerandom.source=file:/dev/urandom //修改tomcat随机数,方便加载8005端口延迟
2019.9.22 Tomcat的三种运行模式 (BIO,NIO,AIO也叫apr)
标签:循环 name ssi form make 复用器 png gre cti
原文地址:https://www.cnblogs.com/otherwise/p/11569170.html