• Post Reply Bookmark Topic Watch Topic
  • New Topic

Max Length of a session

 
vjy chin
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I had a discussion with my friend regarding the how much value can be put into the httpsession. He told me that the max can be 8000 bytes of data can be stored into the session.

Is it true? If not how much data can we store in a session. Also I want to know for an application how many sessions can be there concurrently. I have read somewhere that it is 4096 sessions. Is is true or is it specific to servers?

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He told me that the max can be 8000 bytes of data can be stored into the session.


Seems to me that that would be a fairly easy supposition to test.
 
vjy chin
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,
Thanks for ur reply. How to test it and how would I determine what would be the max. I can store?

Thanks
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems to me to be fairly easy to figure out
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put larger and larger objects into the session until you get an exception. I would bet the size is limited only by memory. I see no reason for an arbitrary session size by default. It's possible a container could have an option to set a size, but the size would have to be recalculated every time a new value is put/updated into the session, and that ignores modifying objects already in the session.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A session is nothing more than a map of references to objects. It's not a container and has no idea how large or small the objects are.
I've never seen anything in the spec about limiting the number of sessions but that's not to say it couldn't be a feature of a specific server implementation.
 
vjy chin
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys,
Thanks for all ur replies. But still if you can tell me how to find it exactly, it would be of great help.

I will also try to put many objects in memory and test the max size.

Please let me know how to get the current size of the session.

Thanks for your help
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vjy chin:
Hey Guys,
Thanks for all ur replies. But still if you can tell me how to find it exactly, it would be of great help.


My point is that the "size of a session" is a vauge concept. In order to know the size of one, you would need to measure the footprint of every object that is referenced by it and all the objects referenced by them and so on and so on. To complicate this further multiple sessions can all reference the same object. This would mean that the total footprint of the app is less than the sum of it's sessions.

You'll get a more accurate idea of your requirements by doing as you've said: Use a profiler to measure the total memory consumption and make comparisons as sessions are added.
 
Sarath Mohan
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I feel it depends on how much memory available for JVM.

Certain tools are available for knowing memory usage of objects.
http://www.ej-technologies.com/products/jprofiler/overview.html

Using this tool you can know the how much a session can hold.

Regards
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please let me know how to get the current size of the session.

We have a major ongoing misconception here caused (I suspect) by sloppy use of terms.
1. You do NOT "put an object in a session" you put a reference to an object in a session.
2. The "size" of the session object in memory is that of any other Map style collection - each entry adds a reference (pointer) to a key String and a reference (pointer) to an object - and that is all.
3. The size of these referenced objects only matters if the servlet container decides to serialize the session. Something not under the direct control of the programmer.

If you are worried about memory use by your servlet, put in some monitoring and reporting functions.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!