I am in need of some suggestions. The app I am working on is going to really strain the DB server, so to lower the load on the server I decided to use sessions. What happens is the servlet gets the data from the server, it is placed into a session and the customer will access the sessions rather than data constantly being requested from the DB. Is this a good method of dealing with the problem ? Or are there better ways of handling such a problem ?
Potentially hundreds, the requests can be large too. The best comparison I can give is like an email webapp. When the user wants to view his inbox, it'll load around 50 emails, with title, 20 words from beginning of email, date sent, receipient etc. So its either between memory (session) or hdd (DB). Sessions are quicker than DB too so thats another reason. I don't think hardware will be too much of an issue. We'll get more servers if needed, but considering you can get servers now with 128GB ram.. What do you guys think ?
Will there be any overlap in the data you're considering storing in the session? In other words, will users A and B both end up storing some of the same data in the session? If so, you might consider storing some common data types at the application level.
While saving the data in the session may work, it's hard to manage, especially if someone just closes their browser without signing off and you have to wait for the session to time out.
Have you looked at various Java caching libraries to reduce the database load? A distributed cache like memcached (search for java memcached) would make things better if you need to run on multiple boxes in the future, too.
Consider serializing the data to a disk file with a unique name that can be associated with a user.
I do this with on-line testservlets using a custom object to hold everything associated with a test session.
Serialization can be surprisingly fast, and with a little effort you can permit a user to resume a session after losing the connection and re-entering the application. Naturally you will need a mechanism to remove old serialized data to keep from filling up your disk.
I would stick to what Dave said. I didn't understand your reply shaf to Deve's question. Is your date user specific?? If not then just put the data in the ServletContext and then you can use it everytime you want. Also store the storing time with the data so that you can update it after a fixed period of time...