aspose file tools*
The moose likes Web Services and the fly likes How to handle app in multiple server instance. Urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "How to handle app in multiple server instance. Urgent" Watch "How to handle app in multiple server instance. Urgent" New topic
Author

How to handle app in multiple server instance. Urgent

Shankar sanjay
Ranch Hand

Joined: Sep 14, 2009
Posts: 117
Hi,

We have RestFul web application, where we are using GlobalApplicationSession HASHMAP from singleton class(SessionSingleTon) to maintain user's session.

Example, whenever users send first request, we will store userObjects(its an instance with xyz properties) in GlobalApplicationSession map

GlobalApplicationSession.put(userid,userObjects);


The same users send a request(2nd, 3rd time) again, we will check GlobalApplicationSession map whether the userid exists, if it exists then we will get some details (from the previous session) and process the curent request.

exmaple to get previous session details.

GlobalApplicationSession.get(userid)


The question is, how can we handle if the application deployed in more than one server(tomcat) using clustered and loadbalancer.


Example:

first time, user1 sends request1 and load balancer direct the request to server1. The userObjects(its an instance with xyz properties) will be stored in GlobalApplicationSession hashmap which is available in server1

2nd time, user1 sends request2 and LOAD BALANCER DIRECT THE REQUEST TO SERVER2, now GlobalApplicationSession (in server2) will not have any userObjects.

How to handle this? can anyone explain?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to handle app in multiple server instance. Urgent