Archive

Posts Tagged ‘was’

WAS静态页面分离技术及动态高速缓存

October 12th, 2011 tonyxu No comments

转自:http://www.javaweb.cc/environment/websphere/091439.shtml

通过IBM Http Server(下文称为IHS)静态页面分离技术与利用WebSpere Application Server(下文称为WAS)的动态高速缓存(Dynamic Cache)技术优化访问页面性能。客户端访问静态页面无须与后端数据交互,减少了容器与数据源的压力,从而达到优化系统的性能。

IBM Http Server不但可以作为 WAS 的前一级 Http 请求队列的缓冲,减轻WAS的压力,还可以利用其静态页面分离方案减轻部分压力。在系统的部署或者构建的时候,我们可以把一些非重要的静态页面放在 IHS 中,当客户端发送请求访问该页面资源时,由IHS直接响应请求并将静态页面资源返回客户端,无须再经过WAS,从而达到减轻达到WAS 负担的目的。
除了IHS静态页面分离方案,另外还可以利用WAS的动态高速缓存技术,将J2EE应用中静态的(Html、Flash、Css、Js、Jpg、Gif图片等文件)和动态的(需要与数据库、Web Service等服务交互才能得到的数据)内容缓存到应用服务器的JVM中(如:Jsp、Servlet、*.do等请求)。在访问相关被缓存的资源时,所有的相关输出都可以直接从JVM的内容中获得,而无须再与数据库、Web Service、静态文件等交互,从而有效地提高系统的性能。
IHS分离静态内容方案

整个操作过程主要分3步完成
n 关闭Was的File Serving Servlet服务
n 重新生成插件(Plugin-cfg.xml)
n 修改IHS配置文件并拷贝静态文件到指定的目录
关闭Was的File Serving Servlet服务
1) 在Was中部署的Web应用中分别找到2个在/WEB-INF/ 目录下面的 ibm-web-ext.xmi 文件。
参考路径:
Ø IBM/WebSphere/AppServer/profiles/节点/conf/cell/applications/应用包名/ deployments/应用包名/应用包名/WEB-INF/目录下
Ø IBM/WebSphere/AppServer/profiles/节点/应用安装部署目录/应用包名/应用包名/WEB-INF/目录下
2) 打开 ibm-web-ext.xmi 文件,找到 fileServingEnabled 属性项,把它设为 flase, 默认是ture。找不到该属性项可直接手工添加(fileServingEnabled="false")。
如:
<?xml version="1.0" encoding="UTF-8"?>
<com.ibm.ejs.models.base.extensions.webappext:WebAppExtension
xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:com.ibm.ejs.models.base.extensions.webappext="webappext.xmi" xmi:id="WebAppExtension_1260496854906"
fileServingEnabled="false">
<webApp href="WEB-INF/web.xml#WebApp_1260496854890"/>
<jspAttributes xmi:id="JSPAttribute_1260496854906"
name="reloadEnabled" value="true"/>
<jspAttributes xmi:id="JSPAttribute_1260496854907"
name="reloadInterval" value="10"/>
</com.ibm.ejs.models.base.extensions.webappext:WebAppExtension>
3) 重启Was,重启完校验配置是否生效。访问Web应用中的静态文件,如会报404错误的,这是正常现象,表示Was中的 File Serving servle 服务功能已经被关闭了。
重新生成插件(Plugin-cfg.xml)
Ø 登陆Was控制台,环境->更新全局 Web 服务器插件配置->确定,重新生成插件。
Ø 服务器->Web服务器->选择相应的web服务器->生产播件->传播插件
Ø 检查配置文件是否正取。
打开IHS/Plugins/conf/web服务名/plugin-cfg.xml.找到UriGroup项,检查其配置。如Uri中的配置还是指定为 Name=”/*”,须注释该行配置,否则IHS会将所有的请求都返回给WAS处理,那么所有访问静态内容都会报404错误。可通过手工配置相应无须过滤的Uri。
具体参考配置如下:
<UriGroup Name="default_host_kpiCluster_URIs">
<!–<Uri AffinityCookie="JSESSIONID"
AffinityURLIdentifier="jsessionid" Name="/*"/> –>
<Uri AffinityCookie="JSESSIONID" AffinityURLIdentifier="jsessionid" Name="/*.do"/>
<Uri AffinityCookie="JSESSIONID" AffinityURLIdentifier="jsessionid" Name="*.jsp*"/>
<Uri AffinityCookie="JSESSIONID" AffinityURLIdentifier="jsessionid" Name="/j_security_check"/>
<Uri AffinityCookie="JSESSIONID" AffinityURLIdentifier="jsessionid" Name="/ibm_security_logout"/>
</UriGroup>
修改IHS配置文件并拷贝静态文件到指定的目录
1) 在IHS的默认路径,打开 \IBM HTTP Server\conf\http.conf文件,找到如下配置:
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "D:\IBM\HTTPServer/htdocs/en_US"
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "D:\IBM\HTTPServer/htdocs/en_US">
可将 D:\IBM\HTTPServer/htdocs/en_US 设置为新的目录,自定义新的静态页面目录。
我们将非重要的静态文件放到E:\PageFiles\2009-12-11\目录下,配置如下:
DocumentRoot "E:\PageFiles\2009-12-11"
<Directory " E:\PageFiles\2009-12-11">
2) 把应用中的静态文件拷到 上述在Httpd.conf配置文件定义好的路径中去。
最后可根据上面的配置,将静态文件都是从Was应用中拷贝到E:\PageFiles\2009-12-11\目录中。
3) 重新启动IHS
通过页面再次访问静态页面,此时不会再出现404错误了,IHS接到请求访问静态页面内容时,会直接读取E:\PageFile\2009-12-11\返回页面请求,通过该配置可以进一步减轻Was的压力。
启用WAS动态高速缓存

启用动态高速缓存服务同样也分为3步
n 在WAS控制台上启用动态高速缓存服务
n 为应用服务器配置 Servlet 高速缓存
n cachespec.xml配置文件
在WAS控制台上启用动态高速缓存服务:
1) 登录Was的管理控制台
2) 在管理控制台中,启用“服务器->应用程序服务器->Server1->容器服务->动态高速缓存服务”
(勾上‘在服务器启动时启用服务’)
3) 确定并保存配置
为应用服务器配置 Servlet 高速缓存:
1) 在管理控制台中,启用“服务器->应用程序服务器->Server1->Web容器设置->Web容器-> 启用servlet 高速缓存
(勾上‘启用servlet 高速缓存’)
2) 确定并保存配置
cachespec.xml配置文件
1) 在应用目录下WEB-INF/下增加cachespec.xml配置文件,通过该文件指定缓存对象。
内容如下:注意红色部分,要正确指定cachespec.dtd文件位置,一般情况下是在/IBM/WebSphere/Appserver/properties目录下。
<?xml version="1.0" ?>
<!DOCTYPE cache SYSTEM "D:\IBM\WebSphere\AppServer\properties\cachespec.dtd">
<cache>
<cache-entry>
<class>servlet</class>
<name>index.jsp</name>
<cache-id>
<component id="*" type="parameter">
<required>false</required>
</component>
<component id="" type="pathinfo">
<required>false</required>
</component>
<component id="host" type="header">
<required>false</required>
</component>
<timeout>180</timeout>
</cache-id>
</cache-entry>
</cache>
2) 在完成前三步后,在服务器上安装Cache Monitor组件,来监控刚才配置的动态高速缓存(Dynamic Cache)是否成功运行。
发布IBM/WebSphere/AppServer/installableApps/CacheMonitor.ear,并且将该应用与要业务应用部署在用一个Server下。
3) 部署完毕后,重启整个WAS。
4) 测试校验部署是否生效。
分别访问:
Ø http://127.0.0.1/index.jsp
Ø http://127.0.0.1/index.jsp?123
通过访问 http://127.0.0.1/cachemonitor 就可以查看到index.jsp已进行了缓存
如图所示:
以上的两种技术一种是基于WEB服务器一级别的优化,另一种则是基于Websphere应用服务器上的优化,合理的使用两种技术,可更有效的帮助应用系统提高性能。
虽然在 WAS V6 以上的版本中,Web Container 对于 Http 请求采用了非阻塞I/O 方式,使得IHS 的这一功能作用已经非常弱化,但在大并发访问的情况下,还是建议大家使用IHS+WAS架构,使用IHS缓冲客户端请求与并且利用其得静态页面技术,直接返回静态资源,减轻应用服务器压力;开启Was动态高速缓存,缓存一些变动较少的Jsp、Servlet等资源,进一步有效的优化系统的性能。分别将IHS与WAS 部署到两台物理主机上,可以让在系统在性能扩展上更加灵活,利用垂直扩展优化可更有效的提高系统的性能。

Categories: WAS Tags: , , ,

Content and maintenance of the wstemp directory for WebSphere

September 20th, 2011 tonyxu No comments

转自:http://www-01.ibm.com/support/docview.wss?uid=swg21315735

 

Question

In WebSphere® Process Server V6, what data and information is stored in the wstemp directory of a custom or deployment manager profile, and what is it used for?

Cause

The wstemp directory of the deployment manager profile includes many files and directories. These take up a lot of space in the file system.

Answer

Each custom or deployment manager profile stores temporary data in the appropriate directory:

<profileRoot>/<profileName>/wstemp
This directory is primarily used by the WebSphere Application Server workspace management component to store temporary session data. After you log in to the administrative console, a new session for the specified user is created to reflect the current operations and configurations. If administrative security is enabled and configured, you must specify a valid user name and password; if you do not, any user name can be used to log in. Depending on the login method, a new subdirectory is created for the user session:
Anonymous login
<profileRoot>/<profileName>/wstemp/anonymous<ID>
Login using a specific user name (and password)
<profileRoot>/<profileName>/wstemp/<userNameHashCode>
The temporary session data is needed as long as a user is logged in. You may observe a high number of created directories in the temporary directory even if no user is logged in. The session directories are deleted by default after a user correctly logs out of the administrative console. If a user closes the Web browser instead of logging out of the administrative console, the directories remain in the file system.
You can safely delete the contents of the temporary directory to free space on the file system. Shut down the deployment manager before deleting the content to ensure that no user is logged in so no open or active sessions become corrupted.
Hint: The temporary directory includes a file named preferences.xml for each user, which stores the console preferences that are configured by that user. If you delete the preferences.xml for a specific user, the administrative console loses the configured preferences, so the user must reconfigure them with the next login. To clean the temporary directory of unnecessary data but keep the preferences configuration file, each user must log out of the administrative console before closing the Web browser.

Related information

Problem with workspace directories
How does wstemp directory work
Clearing wstemp will delete console preferences
Logs and temporary files that can safely be removed

Categories: WAS Tags: , , ,