struts2项目性能调优三步曲
来源:互联网 发布:c gui编程 编辑:程序博客网 时间:2024/04/30 15:42
前一段时间有反映说是一个使用了struts2的生产系统的页面显示速度太慢。登录后发现确实如此,于是进行了一番性能调优的研究和测试。
一,根据struts2官方的性能调优说明进行了一些参数的修改。
http://struts.apache.org/2.x/docs/performance-tuning.html
http://cwiki.apache.org/WW/performance-tuning.html
Turn off logging and devMode.(关闭logging和Devmode)
这个当然没问题,但是全部关闭logging不现实,我只是关闭了struts2相关package的logging
Do not use interceptors you do not need.
把struts.xml中不需要的interceptor统统删除
Use the correct HTTP headers (Cache-Control & Expires).
不确定应该如何修改
Copy the static content from the Struts 2 jar when using the Ajax theme (Dojo) or the Calendar tag.
关于这点,后面会提到
Create a freemarker.properties file in your WEB-INF/classes directory.
照做
Create the freemarker.properties file and add the following setting (or whatever value you deem fitting):
template_update_delay=60000
照做
Enable Freemarker template caching
As of Struts 2.0.10, setting the property struts.freemarker.templatesCache to true will enable the Struts internal caching of Freemarker templates. This property is set to false by default.
照做
进行上述修改后,发现页面打开的速度并没有明显的提高.
二,此时我已经基本锁定网页打开速度慢的原因与ajax(或者说是dojo)有关。因为dojo的js库大概有450K左右,先尝试使用gzip压缩javascript,减小传输量,看能否加快页面的加载速度
在Tomcat的server.xml的connector中添加如下配置,激活gzip功能
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/javascript,application/x-javascript,application/javascript"
进行上述修改后,发现页面打开的速度还是没有明显的提高.
三,经过上述两个实验,觉得应该是struts2所封闭的dojo的性能问题了。于是引入JQuery.
JQuery的js文件最小是55K, gzip后应该更小,页面的响应速度明显改善(一个数量级以上的提高),主要原因在于与服务器交互的处理上极大地提升了效率。而且页面处理代码更加简洁明了。
最后,我删除了所有的<s:head theme="ajax"/>和 <s:head/>(如果页面中加入<s:head />,那么在Struts2生成的html中后包含dojo.js),使用JQuery来完成所有的Ajax和javascript功能。
转自 http://www.blogjava.net/usherlight/archive/2008/07/01/211869.html
- struts2项目性能调优三步曲
- struts2项目性能调优三步曲
- 如何提高struts2性能
- struts2性能优化
- Struts2性能优化
- struts2的性能优化
- 如何提高Struts2的性能
- Struts2性能调优配置
- struts2性能调优配置
- struts2 项目开发经验
- struts2做项目?
- Struts2项目搭建
- Struts2&Hibernate项目经验
- 第一个Struts2项目
- 第一个项目Struts2
- 新建一个struts2项目
- Struts2项目部署
- Spring/Struts2整合项目
- WebLogic 9.2 小问题
- Scala初次接触
- Windows下安装GGobi和rggobi
- MySQL, CFML和Jquery使用中文。
- 哈希表练习
- struts2项目性能调优三步曲
- Struts+spring+hibernate集成的配置文件
- 艳阳照不到向日葵的背面
- 早上喝咖啡的感悟
- 删除一些记忆
- ubuntu-9.04-i386的安装笔记
- Apache https 配置指南
- [分享]SQL语句集锦【强力推荐!】
- c#+sql分页存储过程