简体   繁体   中英

how to reduce usage of HttpSession

In my application, there are many objects in session. Therefore, the size of the HttpSession is high for each user who access my application(It is a Employee information management system). I tried to reduce the objects in session and some time, used the HttpRequest . How ever still session caries many objects which results that the JVM memory usage is high and slow the server. Therefore I need to reduce the session size.

Any solution for this ? Should I add another server and balance the load or upgrade the RAM size of the PC or JVM memory upgrade (If I upgrade so, what will happen in future when more users than now use the system, then again should I have to upgrade the memory?) ? My supposed solution is to add those object into a caching server which runs in separate server(separate PC) instead of the session.
Please let me know your ideas.

Should you add another server? - May be. Should you add RAM and give more memory to JVM? - You could. Will it solve the problem? If the problem is in the design, then it might only upto a certain point. My 1st attempt would be to reduce the objects in session. If that's not possible, have a flat model of that object, you know create a thinned down version of your object which has the bare minimum it needs to be meaningful.

If you still think that all that is done and no significant improvement is noticed, then as Marc suggested, you could try scaling out or scaling up depending on your needs and constraints. Alternatively, you could use Memcached or again as Marc suggested Redis or Mongo if you're okay with persisting sessions and are willing to take a bit of performance hit. I say a bit because these things are real quick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM