• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to maintain data in distributed environment

 
firoz silar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i dn't want to maintain data in session, then how can i maintain data in distributed environment?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not quite clear on your requirements, or what exactly you mean by "distributed environment" (that could be any of a number of architectures), but how about a database?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13077
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some more questions to think about:
1. How much space does this data take?
2. How often does it get generated/changed/deleted?
3. What data structure holds this data?
4. What is the scope this data is used in - single request/web application/entire server?
Bill
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A centralized database has worked for years, long before HttpSession objects were all the rage.

If you know JDBC, and understand databases, using a centralized database can be much more efficient than using an HttpSession. Of course, it can also create an application that extremely difficult to be maintained in the long run, but who cares about the long run when you can write cool JDBC code today!

-Cameron McKenzie
 
firoz silar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my requirements are

1. How much space does this data take?
Ans. may 100 rows from data base

2. How often does it get generated/changed/deleted?
Ans.it won't change frequently. but it changes per day basis

3. What data structure holds this data?
Ans. i dn't know. data stored in oracle data base.

4. What is the scope this data is used in - single request/web application/entire server?
Ans. only single request.

I dn't want put my data in session because our's is cluster environment.
another point here the data base which we interacting is external database, every new request to data base will degrad the performance.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13077
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the data is really only used in a single request there is no need to keep any of it after the response is sent.

If you mean in a single session, then the HttpSession is the ideal place to keep it provided you dont run into memory or cluster problems.

IF you dont have the memory, I would put the data in some Java collection and serialize it to a temporary file, keeping the file name in the session.

Serialization can be surprisingly fast for a simple collection.
Bill
 
firoz silar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it advisable to keep the data in http session in cluster environment?
The session is different for each server in cluster environment.
Imagine there are 3 servers namely A, B and C.
If server A handling the request, If we put some huge data in httpsession.
Again when request comes imagine server A is loaded, then the request goes to server B,
Will I get the same data from httpsession what ever I was put in session?
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you use "sticky" sessions then all requests from a session (HTTP Session) will go to the same server until the session times out.
If you need failover (every server in the cluster can serve your request, you might get different servers between requests) then you would need to replicate the sessions. this might be (depending on the size of the session) expensive.

pascal
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I second the suggestion for using serialization. I've seen it work, and I've seen it work fast. It can get tricky when distribution comes into the picture, but it certainly works, and sounds like it would work well in this scenario.

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic