Make your own free website on Tripod.com

> Hyperactive >>>>>>

>> Author: Sethuraman Ramasundaram>>

1.      >> Introduction >>   1

2.      >> Status >>   1

3.      >> Usage >>   1

4.      >> Usage consideration >>   2

5.      >> Download and Installation (source included) >>   2

6.      >> Configuration >>   2

7.      >> Known issues >>   2

8.      >> Ideas for future versions >>   3

9.      >> Acknowledgements >>   3

 

Share your thoughts in this Hyperactive Blog

 

1.     >> Introduction >>

 

Do you want to display your JSP pages faster? Do you have database calls, Middleware messages and others in the same page which increases the response time? Have you ever wondered if different parts of a JSP could be processed in parallel? Enter Hyperactive. Normally you use jsp:include tag to include any JSP. Hyperactive provides hyperactive:include tag which processes the included JSP in a new thread and does not block the main thread. So if you can divide sections of page into few different includes, then by using hyperactive, you can process all the included JSPs in parallel. In the end of the page, the response from the parent and includes are collected, ordered and flushed to the client.

Hyperactive is JSP on Steroids.

 

2.     >> Status >>

In the alpha version currently, this library is in testing phase – waiting for people to test and provide feedback. You could us help by downloading and testing this. Your comments and suggestions are most important to us, please send it to hyperactivejava@gmail.com

Currently Hyperactive supports weblogic and tomcat application servers. It has not been tested in other appservers and probably might not work. We are working to add support to most of the popular app servers. Check the website for updates and do drop us a mail.

 

3.     >> Usage >>

Hyperactive was designed keeping in mind the simplicity of usage. If you want to use hyperactive for a JSP, then use a <hyperactive:page> at the page starting and a closing tag </hyperactive:page> at the page end. Now if you want to include JSPs, use the <hyperactive:include> tag. This is how the JSP would like:

 

<%@ taglib uri="/WEB-INF/hyperactive.tld" prefix="hyperactive" %>

<hyperactive:page>

            This is parent JSP

            <hyperactive:include page="/child1.jsp"/>

            Some text in parent JSP

            <hyperactive:include page="/child2.jsp"/>

</hyperactive:page>

 

The hyperactive:page tag has an optional attribute “flushAvailableFragments”. If flushAvailableFragments is true(default), then whenever content is available it flushed in a sequential manner i.e. if child1.jsp has completed before child2.jsp, then the output till child1.jsp is flushed to the client. But if child2.jsp completes before child1.jsp, then content is not flushed, but it waits for child1.jsp’s response to be available – to maintain the sequential order in display. If flushAvailableFragments is false then only when all the content is available, the response is flushed out.

 

4.     >> Usage consideration >>

  1. Since the included JSPs are going to be processed in parallel, they should be independent of each other; e.g. child2.jsp should not be expecting a request variable which child1.jsp would have set.  So do all the initialization, in the parent JSP itself, that the child JSP might require, before using the hyperactive:include tag. Also find out whether your child JSPs would be accessing common resources; if so make sure it is thread safe.
  2. Hyperactive was designed to be used only in critical pages where speed of processing is an essential criterion. Remember that more the number of hyperactive threads, more resources would be used; therefore use it in only very minimum number of pages.

 

5.     >> Download and Installation (source included) >>

Hyperactive can be downloaded here

This was tested in Tomcat 5.0 and Weblogic 8.1, but might work in other versions of these app servers too.

Step 1: Place the hyperactive.jar in the WEB-INF\classes directory

Step 2: Extract the file hyperactive.properties to WEB-INF\classes directory. Kindly see the configuration section on know more on the properties of this file.

Step 3: Extract the file hyperactive.tld to WEB-INF directory

 

Download the source code here

Note: There are two packages, starting with org and edu. “org “ is the hyperactive source and “edu” is the source of concurrency library of Doug Lea.

 

6.     >> Configuration >>

The attributes in the hyperactive.properties are:

applicationServer=tomcat (it can be either tomcat or weblogic)

minThreadPoolSize=10 (The number of threads in the thread pool to start with)

maxThreadPoolSize=50 (The max number of threads the thread pool can use)

preallocateThreads=10  (The number to threads to create at startup)

 

7.     >> Known issues >>

  1. Precompilation: A non-precompiled JSP page which uses hyperactive, might not work as expected when it is hit first time
  2. JspWriter: If you want to print from a tag library in parent JSP, then kindly use pageContext.getAttribute(PageContext.OUT) instead of pageContext.getOut() to avoid jumbled display. This issue is present only is parent JSP and not child JSPs

 

8.     >> Ideas for future versions >>

  1. Add an attribute “enable” to hyperactive:page tag. So hyperactive threading could be enable/disabled depending on parameters like time of day(less traffic), user type, etc.
  2. Support other app servers. Right now only tomcat and weblogic are supported.
  3. Add a Admin object for changing the no. of threads, getting statistics etc.
  4. Use a logging API

Your comments and suggestions are most important to us, please send it to hyperactivejava@gmail.com

 

9.     >> Acknowledgements >>

  1. For thread pool management, Doug Lea’s concurrency util library has been used.
  2. Thanks to Prasanna Rajaraman, my best friend (sometimes r is silent) for performing some loadtesting and helping me clear technical hurdles in all projects including this.
  3. Thanks to Saurabh Jain for reviewing my code and always providing technical advice on demand.