JEE: Server Performance and Configuration -Part 2
- Guest Posted by
Anupindi Ravi Shankar, Senior Technology Architect, Manufacturing,Infosys Limited.
In my previous blog post, we talked about WebSEAL configuration settings for performance improvement. In this blog we will discuss on the performance related configuration settings for IBM HTTP server.
Going by the Internet definition, IBM HTTP server (IHS) is a full-featured, cross platform enabled Web server, based on Apache HTTP server (httpd.apache.org) that runs on AIX, HP- UX ,Linux, Solaris, Windows NT and z/OS.
An often and the most common scenario in JEE web applications deployment is that the web server is under utilized by making it as a mere load balancer before the application server cluster. Almost all web servers and especially IBM HTTP server provides many OOTB configurations to improve the web application response time and thereby improving the overall application performance.
In the below depicted illustrative deployment view of JEE web application, IBM HTTP server acts as a load balancer for the application server cluster. If you notice, IBM HTTP server layer itself is clustered enabled to provide high availability and to avoid the single point of failure. We will not be talking about clustering and other deployment related aspects in this blog but would focus mainly on the other capabilities provided by the IBM HTTP server.
Fig1: illustrative Deployment view of the Web Application
Any typical web UI page is composed of the following UI elements in JEE world.
1. JSP template pages.
3. Cascading style sheets (CSS).
4. Images (jpg/png/tif etc.)
Browser makes a separate GET request (as seen in the below snapshot) to download each of the static files from the server. Each such request puts extra burden on application server resources like thread pool, memory, I/O and CPU.In most of the cases the amount of time it takes to process each such request is comparatively high which leads to high response time of the web page.
The better deployment option would be to host the static files on a separate JVM and free application server from serving the static content. This separate JVM can be none other than the web server itself.
The question still prevails is how the new JVM or web server help in reducing the number of GET requests made by the client browser. After exploring many of the configuration capabilities provided the IBM HTTP server, I found the following two configuration options to be most useful and satisfying the desired need.
1. Gzip of static content.
2. Static content caching.
Before I talk about the two configuration settings, it is very important to know that there are 2 different ways to make configuration settings to the IBM HTTP server. The first option is to make changes directly to the main configuration file (i.e. httpd.conf) and the second is to use .htaccess files. The second method allows making configuration changes on a per-directory basis.
Since my experience is with httpd.conf file, I will show how to make configuration settings in this file.
Gzip of static content
To enable HTTP server for Gzip following configuration need to be done in the httpd.conf file.
1. Uncomment the following line
LoadModule deflate_module modules/mod_deflate.so
AddOutputFilterByType DEFLATE text/html text/plain text/css application/x-
Mod_Deflate module provides many other capabilities as shown below:-
By-pass Image compression
Dealing with proxy servers
Setting the compression level
For details pertaining to each of the above settings please refer to the following Apache link
Static content caching
IBM HTTP server provides the following capabilities to cache the static content.
1. Module Expires Header to cache the static content at the browser level.
2. Module cache and mem_cache to cache static content by the web server.
Module Expires Header to cache the static content at the browser level
To enable Expires Header directive following configuration need to be done in the httpd.conf file.
1. Uncomment the following line
LoadModule expires_module modules/mod_expires.so
2. Add the following expires_module
ExpiresDefault "access plus 1 month"
ExpiresByType text/html "access plus 1 month 15 days"
ExpiresByType image/jpeg "access plus 1 month 15 days"
ExpiresByType image/jpg "access plus 1 month 15 days"
ExpiresByType image/gif "access plus 1 month 15 days"
ExpiresByType image/png "access plus 1 month 15 days"
ExpiresByType text/css "access plus 1 day"
Expires: Wed, 17 Sep 2012 21:32:10 GMT
..which indicates to the web browser to cache the corresponding MIME type in its internal cache for the stipulated period of time as mentioned in the Expires attribute. In the above case the browser will cache the corresponding file till 17th September 2012 and will not send any GET request for it and serve the content from Cache. If all the static contents are cached like this then the number of GET requests send by browser will be reduced drastically, thereby improving the response time of the application.
In the above configuration, the expires header are generalized for all MIME types. There can be a scenario where we want to specify different expiry time for static contents of a particular directory without mixing them with the main configuration settings.IBM HTTP server also provides the capability to specify different expiry time for static contents. It can be achieved by adding the corresponding directory to the <location element as shown below:-
ExpiresDefault "access plus 2 hours"
The above configuration specifies that all the images in the /img folder should have the Expires header value set as 2 hours from the access time. It boils down to the fact that the browser will cache these images of this directory for 2 hours and after 2 hours they will again be downloaded from the server. Within 2 hours all the requests for these images files will be served from the browser cache.
The drawback of the above approach is that, it increases the possibility of browser serving the stale content if the corresponding static files are changed on the server. To prevent browser from serving the stale content we can do one of the following:-
1. Enable ETAG in the web server configuration settings.
2. Append timestamp or some unique identifier to the static content URL
Module cache and mem_cache to cache static content by the web server
IBM HTTP server provides the in-memory caching of the static content to further improve the response time to serve the static content. In the absence of in-memory caching I/O operations are performed to serve the static content requests.
To enable mod_cache and mod_mem_cache directives following configuration need to be done in the httpd.conf file
1. Uncomment the following lines
LoadModule cache_module modules/mod_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so
2. Add the following mod_cache and mod_mem_cache
CacheEnable mem /ProductImages
MCacheRemovalAlgorithm GDSF (Greedy-Dual Size Frequency)
For in-depth details of each of the above configuration settings please visit the following Apache link
I hope these HTTP server configurations will come in handy when you are working on performance engineering for your Web Application. Do share with me your experience after using them.
In the next one, I will talk about remaining performance configuration settings for IBM HTTP server.