I'm having a web reporting system developed using J2EE. There are several reports and each of these reports have several columns(8 on an average). The column data can be sorted and filtered.
I have to write a logic to enable the saving of sort and filter for a particular user.
There are 2 flavors here, one is the permanent saving of data, where the data will be saved in the Database. The second one is the temporary saving of data, where the filter/sort data will be saved till the session exists.
Now every time the user makes any filter to any report, I need to save that data so that if the user browses through some other report and comes back, he should see the filtered report.
Now, there are again two options for me to save. The first one is saving the data to session and accessing it from the session variables.
The second one is database again where every time a filter is used, the values will be stored to the DB.
Storing data in the session seems to be a better option for me considering the frequent DB operations to store the temporary data.
My question here is that, is it advisable to store this data to session ? Whats the recommended suggestion for storing the temporary data ?
I just need inputs on whether the session object can be used to significant data.
What is the memory allocated to a session object and does it tend to overflow if the data size increases ?
Kindly help me with this query.
Maybe and then again maybe not
If you are looking for a specific number, it isn't there. It depends on the hardware you use for the server, the memory allocated to the heap, the size and tenure of other objects (besides the session) that uses the heap, the session passivation interval set on your server and many more things.
In effect, you'll have to profile/performance test your application mimicking various load conditions to arrive at a safe answer.
Adi Kulkarni wrote:So does that mean I can implement it using session for now ?
Yes, having a memory overflow just because of storing data on sessions is not that often with the modern day hardware infrastructures. You can implement the session storage and perform some stress testing to find out how it really affects. If it's getting bigger, you may need some horizontal scaling on a distributed environment.