[size=1.25em]4、JNI加速 resin不使用NIO而是使用了JNI的方式使用本地码的方式来提升效率,经验证,resin使用JNI的效率要高于使用NIO,
使用JNI是需要对resin进行编译,在./configure时把jni编译进去,
./configure --enable-jni 美中不足的是Resin Professional版本才提供此项功能。
下面是resin-doc的说明:
Resin does not use NIO - it uses JNI to handlelow-level I/O calls with native code. The performance using this methodwas found to be much better than nio. [size=1.25em]5、jsp第一次编译的处理 一般来讲,第一次访问jsp会自动进行编译,如果更新了过多的jsp、且系统访问很大的话,重启resin容易造成负载过高。
下面配置是启动app-server时,对所有的jsp进行编译,编译完毕后启动监听,这样启动时间会长一些,但是可以防止第一次访问编译造成系统负载大。
<listener>
<listener-class>com.caucho.jsp.JspPrecompileListener</listener-class>
<init>
<extension>jsp</extension>
<extension>jspx</extension>
</init>
</listener> [size=1.25em]6、resin 与apache 性能的比较 resin3单独使用时性能也是不错,当然也可以跟apache配合使用。下面是resin-doc中的说法:
ForJSP and Servlets, Resin standalone is certainly faster thanResin/Apache. Because of the extra overhead of the Resin/Apacheconnection, the Resin/Apache configuration is necessarily slower thanResin standalone.
可以看出各有优劣,
apache对于静态页面来说比较快。如果使用了SSL,apache+resin要比resin单独使用快一些,更为重要的是resin3的开源版本不支持ssl。
[size=1.25em]7[size=1.25em][size=1.25em]、resin-server TIME_WAIT 过多的处理 thread-max指定了最大连接数,socket-timeout是socket超时时间
keepalive-max指定了长连接的数量,这是可以重复使用的连接,netstat -an时系统可以看到响应数量的ESTABLISHED状态
设定keepalive-max和把keepalive-timeout调小可以减少TIME_WAIT的数量。
<thread-max>256</thread-max>
<socket-timeout>65s</socket-timeout>
<keepalive-max>128</keepalive-max>
<keepalive-timeout>120s</keepalive-timeout>
一般来讲如果是Resin standalone方式,调整timeout并不是很重要,如果是apache+resin的方式,而且apache压力很大的情况下,需要调小timeout的值。
load-balance-idle-time是用来设置load-balance和分布式session的关闭时间,默认时间为keepalive-timeout - 1s
<load-balance-idle-time>100s</load-balance-idle-time> [size=1.25em]8、关于watchdog resin3启动是多了一个watchdog的进程。可以单独启动也可以跟随resin.jar一起启动,主要是用来监控resin jvm实例,在必要的时候重启。
<watchdog-jvm-arg>-Dcom.sun.management.jmxremote</watchdog-jvm-arg>
<watchdog-port>6600</watchdog-port>
查看 watchdog 状态
java -jar lib/resin.jar status
Resin/3.1.6 status for watchdog at 127.0.0.1:6600
server '' : active
password: missing
user: root
root: /home/resin/
conf: /home/resin/conf/resin.conf