• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Do sessions use hashing?

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do sessions use hashing to organize their data?
I assume this is container-specific. I wonder if I would get a perf boost from adding hashCode method to objects that I'm putting in my sessions for Tomcat.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont have knowledge of how session attribues are implemented for any particular container, but consider that the session attribute key is always a String. So if a Hashtable/HashMap is being used to store the attributes (as I would guess is probably the case), it is the hashCode() and equals() method of the String key that would be used, not any such methods that are defined in your class.
Mark
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Tomcat and presumably other servlet engines, a session object is tracked using the sessionID (a String) as a key in a Hashtable or similar collection. Inside the session named objects are stored in a Hashtable keyed by the name (a String). This is already very efficient.
Of all the many things affecting performance in Servlets, the session mechanism is probably the least important.
The number one place to look for time wasting (IMHO) is anywhere you build up Strings and print them to the response.
(Unless you are doing JDBC queries in which case look there for time wasting).
Bill
 
Garrett Smith
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, sessions use Strings for keys. What was I thinking?
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Of all the many things affecting performance in Servlets, the session mechanism is probably the least important.


I think the specifics of the in-memory mechanism itself aren't very important, but being aware of the volume/frequency of session updates by the application is critical for scalability.
It is especially important for a cluster, where agressive session persistance settings in the container config may cause modifcations to the session to persist directly to a datasource.
These concerns are probably more architectural than impementation, but everyone along the way should be aware.
JMHO,
Chris
[ April 06, 2003: Message edited by: Christopher Dixon ]
[ April 06, 2003: Message edited by: Christopher Dixon ]
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good point Christopher.
Incidently, if you are interested in performance traps in server applications, Bitter Java by Bruce Tate makes a great read. Sort of an anti-patterns collection for web applications.
Bill
reply
    Bookmark Topic Watch Topic
  • New Topic