Skip to content


优化 tomcat session和thread

Server Information
Tomcat Version :Apache Tomcat/6.0.16
JVM Version :1.6.0_10-beta-b24
JVM Vendor :Sun Microsystems Inc.
OS Name :Linux
OS Version :2.6.9-5.ELsmp
OS Architecture :i386

问题
应用为lucene全文搜索;
当php的缓存失效时会带来大量不经过squid的请求,导致半天搜索结果不出来,php占用大量cpu,系统一直满负载

解决方法
1.增加php缓存时间同时加上随机时间让请求分散
2.增加tomcat的并发能力

首先打开tomcat的管理功能方便查看状态
编辑conf/tomcat-users.xml增加用户






重启tomcat
请求http://localhost:8080/manager/html
可以看到当前各应用的session数,内存占用,线程数…

优化1:减少session生命周期
编缉conf/web.xml将默认的30分钟改成5分钟


5


也可以编辑各应用下的web.xml针对应用进行调整

优化2:增加线程数
编辑conf/server.xml,修改默认40到100


优化3:增加内存
优化tomcat 内存

优化后server status
JVM
Free memory: 589.87 MB Total memory: 1162.43 MB Max memory: 1162.43 MB
http-8080

Max threads: 100 Current thread count: 26 Current thread busy: 6
Max processing time: 7545 ms Processing time: 4180.072 s Request count: 14471 Error count: 142 Bytes received: 0.00 MB Bytes sent: 297.62 MB

Posted in Tomcat, 技术.

Tagged with , , .


No Responses (yet)

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.