• Post Reply Bookmark Topic Watch Topic
  • New Topic

while implementing clustering why shouldn't i use Servlet application scope and stat  RSS feed

 
kesava chaitanya
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
while implementing clustering why shouldn't i use Servlet application scope and static variables at code level
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should not use application scope or stratic variables while using clustering because in that case, each server will have its own 'context' and its own copy of the static variables which are not shared across the servers.
To add to this, even session variables are not shared, so if the first time a user logged in to a Server A in a cluster and a session was created for him, if his next requst is serviced by server B, server B has no knowledge about his session object on server A and hence B would create a new session object for him.

The same logic applies to the context(application scope) and static variables as well.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clustering ususally involves session replication.
Your other points are certainly correct though.
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben,

Does it 'usually' allow session replication, or does it 'always' allow session replication?

I am asking because some of my colleagues faced that problem while doing something on clustering. I was surprised as to why sessions were not replicated because I would think they would be, but werent.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends how clustering is enabled.

Clustering using multiple separate application server instances and a load balancer is simple but will not share sessions.

Clustering using a configured cluster of application servers requires more work and a server which supports clustering and should support clustered sessions. There are other options here such as 'server affinity', where requests from a client are always sent to the same server instance. In this case, the sessions are kept on a single box but are sometimes backed up on a second in case that instance goes down.

Our application uses the first sort (hardware load balancer) with a stateless web layer, although the client retains a token to allow the web layer to communicate the state to the next level down.

I guess there are session and then there are session.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ours uses IP Load Balancing or "Server Affinity" (users are kept to one server by IP) at the router level. I don't really consider this a cluster.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:
Ours uses IP Load Balancing or "Server Affinity" (users are kept to one server by IP) at the router level. I don't really consider this a cluster because I can't pull one server out of the mix without interrupting service to some clients.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!