1) 优化JVM参数
这个参数可以在resin.xml 里直接配置,不过,要按照顺序放在 <cluster id="app"> 下面,不能放在其他<server>标签下面,否则jvm参数会失效。
推荐:
将 -Xms和-Xmx 设为相同值; -Xmn值约等于-Xmx的1/4。
<server-default>
<jvm-arg>-Xms1024m</jvm-arg>
<jvm-arg>-Xmx1024m</jvm-arg>
<jvm-arg>-Xmn256m</jvm-arg>
<jvm-arg>-XX:PermSize=128m</jvm-arg>
<jvm-arg>-XX:MaxPermSize=256m</jvm-arg>
<thread-max>512</thread-max>
<socket-timeout>30s</socket-timeout>
<keepalive-max>512</keepalive-max>
<keepalive-timeout>15s</keepalive-timeout>
</server-default>
2)session 优化配置
注意 resin.conf与项目配置web.xml同时配置timeout,则服务器配置优先级最高。
session-max:会话数量,session-timeout 超时时间,单位分钟
<session-config>
<session-max>4096</session-max>
<session-timeout>30</session-timeout>
<enable-cookies>false</enable-cookies>
<enable-url-rewriting>true</enable-url-rewriting>
<file-store>WEB-INF/sessionsx</file-store>
</session-config>
3) 禁止session 持久化
修改 resin.properties 中
session_store : false
其他也可以设置false
resin_doc : false
dev_mode:false
web_admin_enable : false
4)防止 Hash Collision DoS
<web-app id="/" root-directory="/xxx">
<form-parameter-max>100</form-parameter-max>
</web-app>
5) 禁止热部署
<dependency-check-interval>-1</dependency-check-interval>
6)连接设置
socket-timeout 和 keepalive-timeout 可以适当调小
最大线程数
<!-- Maximum number of threads. -->
<thread-max>1024</thread-max>
<socket-timeout>30s</socket-timeout>
<keepalive-max>512</keepalive-max>
<keepalive-timeout>15s</keepalive-timeout>