Wednesday, June 1, 2011

Improving WebCenter Performance – Part 1

Tuning is quite a long and complex subject to be discussed in a single article. This first post will cover 2 basic strategies to make your Oracle WebCenter installation faster by tweaking the browser caching and adding content compression. By the end of this article your WebCenter pages should be rendering in less than 2 seconds – obviously depending on your environment – and with fewer requests.

Browser Caching


Your browser has a folder in which certain items that have been downloaded are stored for future access. Images, stylesheets, javascripts, and even entire web pages are examples of cached items. When accessing a website, your browser will check its cache folder first to see if it already has those images and, if so, it won't take the time to download them again.
There are two main reasons that web caches are used:
To reduce latency — Because the request is satisfied from the cache instead of the web server itself, it takes less time for the representation to render in the browser.
To reduce network traffic — Since there are less items to be downloaded from a web site, it reduces the amount of bandwidth used by a client.
Like in any other application, WebCenter Portal have static resources that need to be cached by the browser in order to reduce subsequent download access. The trick here is to setup OHS to rewrite the HTTP header of some specific virtual paths related to static resources in WebCenter.
We will use max-age instead of Expire. The max-age directive specifies the maximum amount of time that a representation – or file - will be considered fresh. From my perspective, the big advantage of this directive is that it’s relative to the time of the request, rather than absolute. max-age also seems to behave better with IE in general. I haven’t checked that in IE 9 so far. For this exercise, we’ve setup max-age to 2592000 seconds (30 days).

Header unset Last-Modified
Header unset Expires
Header set Cache-Control "max-age=2592000, public"
Header set Surrogate-Control "max-age=2592000"

Content Compression


To do content compression in OHS you need to configure mod_deflate. It should already be installed in your OHS under $MIDDLEWARE_HOME/Oracle_WT1/ohs/modules/mod_deflate.so. But it might not be loaded.

LoadModule deflate_module        "${ORACLE_HOME}/ohs/modules/mod_deflate.so"

With mod_deflate, you can compress HTML, text or XML files to approx. 20 - 30% of their original sizes, thus saving you server traffic. However, compressing files causes a slightly higher load on the server, but again, clients' connection times to your server decrease a lot.

mod_deflate requires you to specify which type files are going to be compressed.

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/html

Images are supposed to be in a compressed format, and therefore are bypassed by mod_deflate.
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

Quick Setup


To have all those changes applied to your environment, please download webcenter.conf and replace the variables listed below accordingly.
  • [wc_spaces host]
  • [wc_spaces port]
  • [wc_services host]
  • [wc_services port]
  • [ses host]
  • [ses host]
If you already have portlets being consumed by your application, don’t forget to add the proper mod_wl entries.

#Portlets
#Insert your portlet mapping here
<Location /[portlet path]>
SetHandler weblogic-handler
WeblogicHost [wc_portlet host]
WeblogicPort [wc_portlet port]
</Location>
 

And if you have already separate the static assets from your application into a different directory, you might want to set the same configuration:

Alias /[virtual path for static files] [physical path for static files]
 
<Location /[virtual path for static files]/>
Header unset Last-Modified
Header unset Expires
Header set Cache-Control "max-age=2592000, public"
Header set Surrogate-Control "max-age=2592000"
</Location>

After doing the proper setup you can drop the webcenter.conf file into $MIDDLEWARE_HOME/Oracle_WT1/instances/instance1/config/OHS/ohs1/moduleconf. You MUST restart OHS for the changes to take effect.

TESTING


Now let’s access WebCenter to see how fast it is. The first access any WebCenter Spaces page should be faster since we’re using content compression, but it should still bring lots of resources such as js files, images, css, etc.
1st Access
Capture
Activities page renders in approximately 7.5 secs with 91 requests.
2dn Access
Capture2
A subsequent access to the same page takes less than half a second and only requires a single request. All other static assets are cached by the browser and don’t need to be downloaded again.
Others
Any other request to pages that haven’t been accessed before should take less requests to render, since most of the WebCenter resources have been downloaded previously.
Capture3
Spaces page takes 1.1 seconds and 7 requests to render. Blazing fast, my friends!

2 comments:

Note: Only a member of this blog may post a comment.