Polishing your Portal with a High-Load Page

When your servers become overloaded with requests, they're unable to your end users with the experience you desire.  It's important in these situations to fail gracefully so that your end users (customers, employees or whomever it may be) don't become frustrated with your site.  We wanted to provide a customized high-load page so that our site:

  • Fails gracefully for users trying to connect, and minimally affects users who are already connected
  • Looks a more polished and professional
  • Is guaranteed to provide a known QoS to our customers

The portal we're customizing is based on Liferay.  In our case, we didn't like the error page that Liferay provides by default when using the session.max.allowed property, so we decided to do some customizations.

To do so we added a redirect to a high load page based on the user session count.  The high load page is an extremely simple page.  We're using static HTML served by Tomcat, and we made it as light weight as possible.  Serving the page with Apache HTTP would be better, however we don't have the option to do so in our system.

There were 4 steps to adding this page:

1. Add custom properties to portal-ext.properties file

2. Create a class that tracks the session count
 - Use a listener to track the number of sessions , increasing count on creation and decreasing count on destroy
 - There are several examples of doing this on the web, i.e.
 - http://tomcat-configure.blogspot.ca/2009/01/tomcat-session-listener-example.html
 - The listener must be added to the web.xml in your Liferay ext plugin

3. Check session count in all desired classes that extend HttpServlet
  - Must be done in the Liferay ext plugin, follow proper ext patterns explained at www.liferay.com
  - If too high (above threshold in portal-ext.properties), redirect to low load page and invalidate session
    - Redirection page should be in portal-ext.properties to allow it to be reconfigured without recompiling the code (and redeploying the ext plugin)

4.  Create a very simple target page that will result in minimal server load
 - In our case I just created a directory in webapps (using tomcat) with an index.html file
 - index.html contained simple message explaining we're experiencing higher than normal load, please re-visit the site later