The Artima Developer Community
Sponsored Link

Java Buzz Forum
Session Clustering with Hazelcast Webapp Manager

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Talip Ozturk

Posts: 103
Nickname: talip
Registered: May, 2003

Talip Ozturk is founder of Hazelcast, distributed queue, set, map and lock implementation.
Session Clustering with Hazelcast Webapp Manager Posted: Jul 23, 2008 4:49 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Talip Ozturk.
Original Post: Session Clustering with Hazelcast Webapp Manager
Feed Title: Shared Memory
Feed URL: http://www.jroller.com/talipozturk/feed/entries/rss
Feed Description: about java, jcache, jini, javaspaces, distributed data structures and a little bit of me and life.
Latest Java Buzz Posts
Latest Java Buzz Posts by Talip Ozturk
Latest Posts From Shared Memory

Advertisement
Hazelcast Webapp Manager is a session clustering and monitoring tool for Java web applications. In short, Hazelcast takes .war file and creates a clustered and monitorable version of it (clustered-.war). It is that simple.

This is well-known stuff but here is a common use-case scenerio: You have a web application that uses HttpSession object to store your session scoped data. And your application is or will be running on more than one server for load-balancing. So you have got a loadbalancer (appliance or software) and your application is running on more than one web server, behind the loadbalancer. You don't persist your sessions onto a database, disk, or distributed hashtable. What happens if a web server goes down? All the sessions go down with it. User will be routed to one of the remaining live servers by the loadbalancer but the user loses his/her session. So if you use Hazelcast Webapp Manager, no losing sessions after crashes.

Besides that, Hazelcast Webapp Manager lets you get statistics on your running application. Hazelcast Webapp Manager collects statistics like number of created/destroyed sessions, average session data size, number of requests, average response time, min. and max. response times for a given time interval (x seconds). So it is like taking a snapshot of the running application every x seconds and passing it to the listeners as a SnapshotEvent. Here is a sample servlet that listens for SnapshotEvents.

public class MonitoringServlet extends HttpServlet implements SnapshotListener {
	 
	public void init(ServletConfig config) throws ServletException {
		super.init(config);		
		((HazelServletContext)config.getServletContext()).addSnapshotListener(this);
	}

	public void service(ServletRequest req, ServletResponse res) throws IOException, ServletException {
		//do something here
	}

	public void handleSnapshot (SnapshotEvent snapshot) {
		System.out.println("===== Here is the metrics of the last 30 seconds ======");
		System.out.println(snapshot);
		System.out.println("ave.  session data size : " + snapshot.getAverageSessionDataSize());
		System.out.println("ave.      response time : " + snapshot.getAverageResponseTime());
		System.out.println("min.      response time : " + snapshot.getMinResponseTime());
		System.out.println("max.      response time : " + snapshot.getMaxResponseTime());
		System.out.println("# of           requests : " + snapshot.getNumberOfRequests()); 
		System.out.println("# of       new sessions : " + snapshot.getCreatedSessionCount()); 
		System.out.println("# of destroyed sessions : " + snapshot.getDestroyedSessionCount()); 
		System.out.println("=======================================================");
	}
}
So you might want to send email if average response time gets bigger than ,say, 5 seconds or send an SMS to the system admin if there is no requests for that last 30 seconds to check if there is anything wrong. Or you may want to develop a front end to show these metrics with nice graphics, charts etc.

No release avaliable but as I am developing and testing it locally, before I release anything I am looking for answers for the following questions:
1. I named it 'Hazelcast Webapp Manager'. A better name maybe?
2. What else would be nice to have it in SnapshotEvent?

By the way, new downloadable on the site has the source code of the command line Test application. I used to send that code via email, I will save time by including it in the distro :) You can change the code for your own testing purposes if you want.

Read: Session Clustering with Hazelcast Webapp Manager

Topic: Late 4 Work Previous Topic   Next Topic Topic: links for 2008-07-14 from PeopleOverProcess.com

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use