Performance tuning
The following are some tips and tricks to squeeze the most performance out of Struts 2.
Turn off logging and devMode.(关闭logging和devMode)
DevMode allows reloading of configuration and validation related files, but because they happen on each request, this setting will totally kill your performance.
When using logging, make sure to turn off logging (esp. Freemarker generates a LOT of logging), and check if a level is enabled before printing it, or you will get the cost of the String parsing/concatination anyways.
Do not use interceptors you do not need.(不要使用你不需要的拦截器)
If you do not require a full stack of interceptors for an Action, then try using a different one (basicStack), or remove interceptors you do not need.
Use the correct HTTP headers (Cache-Control & Expires).(使用正确的HTTP头(缓存控制和过期时间))
When returning HTML views, make sure to add the correct headers so browsers know how to cache them.
Copy the static content from the Struts 2 jar when using the Ajax theme (Dojo) or the Calendar tag.(当使用AJAX theme(Dojo)或日历tag时,从Struts2的jar包复制静态内容到http服务器)
Struts 2 uses some external javascript libraries and cascading stylesheets for certain themes and tags. These by default are located inside the Struts 2 jar, and a special filter returns them when requesting a special path (/struts). Although Struts 2 can handle these requests, an application/servlet container is not optimized for these kind of requests. Consider moving these .js and .css files to a seperated server (Lighttpd, Apache HTTPD, ..).
Create a freemarker.properties file in your WEB-INF/classes directory.(在WEB-INF/classes目录,新建一个freemarker.properties文件)
Create the freemarker.properties file and add the following setting (or whatever value you deem fitting):
This value determines how often Freemarker checks if it needs to reloads the templates from disk. The default value is 500 ms. Since there is no reason to check if a template needs reloading, it is best to set this to a very large value. Note that this value is in seconds and freemarker will convert this value to milliseconds.
See also: Freemarker configuration properties
Enable Freemarker template caching(激活Freemarker模板的缓存)
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.
In Struts versions prior to 2.0.10, you had to copy the /template directory from the Struts 2 jar in your WEB_APP root to utilize Freemarker's built in chaching mechanism in order to achieve similar results.
The built in Freemarker caching mechanism fails to properly cache templates when they are retrieved from the classpath. Copying them to the WEB_APP root allows Freemarker to cache them correctly. Freemarker looks at the last modified time of the template to determine if it needs to reload the templates. Resources retrieved from the classpath have no last modified time, so Freemarker will reload them on every request.
When overriding a theme, copy all necessary templates to the theme directory.(当覆盖一个theme时,copy所有重要的模板到theme目录
)
There's a performance cost when a template cannot be found in the current directory. The reason for this is that Struts 2 must check for a template in the current theme first before falling back to the parent theme. In the future, this penalty could be eliminated by implementing a missing template cache in Struts 2.
Do not create sessions unless you need them.(在你需要的时候才创建sessions )
Struts 2 does not create sessions unless asked to (for example, by having the createSession interceptor in your interceptor stack). Note that when you use SiteMesh however, a session will always be created (See http://forums.opensymphony.com/thread.jspa?messageID=5688 for details).
When using Freemarker, try to use the Freemarker equivalent rather than using the JSP tags.(当使用FreeMarker时,尽量使用等价的FreeMarker元素,代替JSP的标签)
Freemarker has support for iterating lists, displaying properties, including other templates, macro's, and so on. There is a small performance cost when using the S2 tags instead of the Freemarker equivalent (eg. <s:property value="foo"/> should be replaced by ${foo}).
引自http://wangrui.iteye.com/blog/153769
http://struts.apache.org/2.0.11/docs/performance-tuning.html
相关推荐
实用经典的9i教材,虽然oracle11g出了很久了,但是9i教材撰写的还是非常详细和经典的。相对11g糟烂晦涩的教材来说,是绝对不可替代的。 对于新手来说是必备的首选教材。 多收两分,可以理解吧.... ...
Oracle 11gR2 Performance Tuning 性能优化 参考手册
### Oracle Database 12c Release 2性能调优技巧与技术 #### 一、引言 随着企业数据量的不断增长和技术的快速发展,确保数据库高效运行成为IT部门的一项关键任务。Oracle Database 12c Release 2(简称12c R2)...
“2 Day + Performance Tuning Guide”是一份全面的指南,为Oracle DBA和系统管理员提供了丰富的性能调优资源。通过合理利用Oracle Diagnostics Pack、Oracle Database Tuning Pack和Oracle Enterprise Manager等...
Oracle Database 12c Release 2 Performance Tuning Tips and Techniques是当前数据库专业人士必须掌握的高级资料。从给出的描述和部分内容来看,该资源提供了大量的性能调整技巧和最佳实践,以帮助DBA(数据库管理...
《Oracle® Database 2 Day + Performance Tuning Guide》是一本由Oracle官方提供的、针对Oracle 10g Release 2 (10.2)版本数据库性能调优的专业指南。本书主要介绍了如何使用Oracle Diagnostics Pack、Oracle ...
本文将根据《Oracle Performance Tuning Guide》的内容,详细介绍Oracle数据库性能调优的相关知识点。 #### 二、性能调优概述 性能调优是指通过一系列技术和方法来提高系统或应用的响应速度和吞吐量的过程。对于...
本文将依据IBM红皮书《Database Performance Tuning on AIX》的内容,深入探讨在AIX上进行数据库性能调优的方法和技术。 #### 关键知识点详解 ##### RDBMS(关系型数据库管理系统)性能特性深度剖析 - **定义与...
《Oracle® Database 2 Day + Performance Tuning Guide》(11g Release 2(11.2)版)是一本全面介绍Oracle性能调优的专业指南,由Lance Ashdown、Immanuel Chan等多位Oracle专家共同编写。 #### 书籍概述 本书...
《Oracle® Database Performance Tuning Guide》是一本非常实用的性能调优指南,它不仅提供了丰富的理论知识,还有大量实践经验和技巧分享。无论是初学者还是有一定经验的专业人士,都能够从中获得有价值的信息,...
### Linux性能调优指南 #### 一、理解Linux操作系统 **1.1 Linux进程管理** - **1.1.1 进程的概念** - 在Linux系统中,进程是资源分配的基本单位,也是运行程序的基本单位。每一个正在执行的程序都是一个进程。 ...
本书《Java Performance Tuning, 2nd Edition》由Jack Shirazi编写,旨在为Java开发者提供全面且深入的性能调优指南。无论是对初学者还是经验丰富的开发人员来说,书中涵盖的知识点都是极其宝贵的资源。 #### 二、...
#### 环境性能调优概述 本章节主要介绍在WebSphere Portal V6.0环境下如何进行系统性能调优。性能调优是确保应用程序能够在高负载下保持稳定运行的关键步骤。通过对应用服务器、数据库服务器、目录服务器以及网络等...
Performance Tuning Guide11g Release 2 (11.2)E41573-03September 2013Oracle Database Performance Tuning Guide, 11g Release 2 (11.2)E41573-03Copyright :copyright: 2000, 2013, Oracle and/or its affiliates...
2. **性能调优**:通过对连接池参数的调整,优化数据库访问性能,提高系统响应速度。 3. **问题诊断**:利用PTT提供的工具定位内存泄漏的具体位置,并采取相应的措施解决。 #### 八、总结 综上所述,WebSphere ...