• 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

Best practices in Enterprise applications for session persistence

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are the best pracices to persist session and cross session data in a enterprise application which can be used commonly by the servlet layer as well as the EJB Layer.Currently we are using static HashMap to store and retrieve these data which indeed are consuming lot of App Servers Heap Memory.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Static data structures cannot be used in EJBs, unless they are read only. If you've got one you'll need to get rid of it.

If your cached data is required in both tiers the sensible place to store it is in the EJB layer. To do this you have the option to
  • use stateful beans and redundantly replicate it
  • implement a distributable cache and use that
  • use another persistent store, such as a database


  • If you only need this data in the Servlet tier an easier option might be to use one of many caching mechanisms available. These are very configuable allowing you to set all the stuff you might want (max life in cache, max number objects in cache, max memory per object, max total memory, second level cache etc.) A down side would be that this cache would not work in a cluster, unless you also made it distributable.
     
    venki sheshgiri
    Greenhorn
    Posts: 28
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    implement a distributable cache and use that

    What is the best way to implement distributable cache I would like avoid scenarios where a DB Query or properties file loading are involved.
     
    author & internet detective
    Posts: 41878
    909
    Eclipse IDE VI Editor Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    venki sheshgiri wrote: which indeed are consuming lot of App Servers Heap Memory.


    This is going to happen with any caching solution. The data needs to be stored somewhere if it's not going to be read from disk or database.

    venki sheshgiri wrote:What is the best way to implement distributable cache


    It's more commonly called a "distributed search." When you look for an open source or commercial one, it helps to be looking under the name people list it as. You definitely should not "implement" a distributed cache. It is complex and very difficult to get right. This list of open source Java caches list which are distributed.

    venki sheshgiri wrote:[ I would like avoid scenarios where a DB Query or properties file loading are involved.


    Some caches work via replication. Which does use network traffic of course, but not a DB query. I can udnerstand why you want to get a potentially expensive DB query out of the picture, but what's wrong with reading from a property file and caching that?
     
    Paul Sturrock
    Bartender
    Posts: 10336
    Hibernate Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator


    It's more commonly called a "distributed search."


    Not the thing I was suggesting. I was thinking along the lines of EHCache, JCA, JavaCache etc. rather than a full blown information retreival technology. If all you want to do is cache some stuff in an JEE application is an IR technology not overkill?


    but what's wrong with reading from a property file and caching that?


    An edge case true, but this is suspect in a cluster.
     
    venki sheshgiri
    Greenhorn
    Posts: 28
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Paul,Jeanne Sorry for posting late was busy with some Crystal Report Issue.
    Paul you got me why I dont want do it using a properties File. Ideally we deploy our Enterprise Application in Horizontal Cluster Setup and we need to address Server Failover,Request Hopping Scenarios between two Application Server Nodes.
     
    Ranch Hand
    Posts: 2187
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    The best practice was already mentioned, use a relational database to manange session data.
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic