aspose file tools*
The moose likes Performance and the fly likes Max. size of HttpSession attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "Max. size of HttpSession attribute" Watch "Max. size of HttpSession attribute" New topic
Author

Max. size of HttpSession attribute

Shiva Shankar
Ranch Hand

Joined: Dec 07, 2006
Posts: 31
Hi All,

What could be the max. size of session attribute?
Is it feasible to keep attribute(xml data) of size between 30-50KB in HttpSession in prodution environment.

Thanks in advance.
Shiva
Shashank Ag
Ranch Hand

Joined: Dec 22, 2009
Posts: 88

It always comes down to how much resources you have on server jvm (RAM).
J2EE does not have any limit of session size.


SCJP 91%, SCWCD 97%
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Remember that your attribute will presumably exist for each session in the application. So if you put large objects in memory you will limit the amount of concurrent users your server can support. You also need to be mindful of aggressively releasing resources (i.e. short session timeouts, JavaScript to try to remove sessions on browser close and garbage collection tuning). That being said, 30-50KB is not a massive amount given the relative cheapness of memory these days.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30758
    
156

As long as you not replicating or persisting the session data to support multiple clones, large sessions are ok. And of course assuming you have enough memory. If you are replicating/persisting, you are creating a lot of extra work for the server by having a large session.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

Is it feasible to keep attribute(xml data) of size between 30-50KB in HttpSession in prodution environment.


Parsing this data and storing light weight objects would be a better choice. I do not know the context of your problem, so the last sentence may not apply. 50KB does not seem like much, but if multiple sessions store the same size, it will start to load the server memory when enough folks log in.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

... Or, just to say it all yet another way.

1. The RAM requirements for your webapp are going to be x + su * s, where "x" is everything else, "su" is the maximum number of concurrent session users, and "s" is the session object size itself. So, if this is an app with no more than 5 users, go for it. If it has 1500 users, you may want to reconsider.

2. The time required for serialization/deserialization of each session object is going to increase more or less linearly with the size of the object. So if lots of serial transformations are expected, be prepared.

Incidentally, I was (am) working with a web service where the SOAP API was defined by a company which is less talented than it is successful. It rammed several hundred KB worth of XML into my server code - which WAS, BTW stored as a session object in RAM. And blew it off.

Actually, the real pain wasn't so much the size of the session object, but of all the memory overhead while the serialization mechanism built a DOM out of it. Probably took 4x or more RAM to do that than it did to hold the final product.


Customer surveys are for companies who didn't pay proper attention to begin with.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

while the serialization mechanism built a DOM out of it


Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

Deepak Bala wrote:
while the serialization mechanism built a DOM out of it




The serialization mechanism in question was called "Apache Axis". Maybe Axis2 handles it better, but I haven't had time to convert.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

Tim Holloway wrote:
Deepak Bala wrote:
while the serialization mechanism built a DOM out of it




The serialization mechanism in question was called "Apache Axis". Maybe Axis2 handles it better, but I haven't had time to convert.


If I understand correctly, your server side code calls a WS which uses "Apache Axis" ? Are you referring to the marshalling / unmarshalling of the XML (in)to java objects ?

Feel free to correct me if I misunderstood
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Max. size of HttpSession attribute